Skip to main content
Glama
CubeAPM MCP Server

CubeAPM MCP Server

query_logs

Search CubeAPM logs using LogsQL syntax to find errors, filter by labels, and aggregate results. Returns matching log entries within a time range for debugging and investigation.

Instructions

Query logs from CubeAPM using LogsQL syntax (VictoriaLogs compatible). Returns log entries matching the query.

IMPORTANT - Log Label Discovery:

  • Labels vary by source! Use "*" query first to discover available labels

  • Lambda logs use: faas.name, faas.arn, env, aws.lambda_request_id

  • Service logs may use: service_name, level, host

  • NOT all sources have "service_name" - check the _stream field in results

LogsQL Query Syntax:

  • Wildcard (discover labels): *

  • Stream filters: {faas.name="my-lambda-prod"}

  • Text search: {faas.name="webhook-lambda-prod"} AND "error"

  • Regex match: {faas.name=~".*-prod"}

  • Negation: {faas.name!="unwanted-service"}

  • Combine filters: {env="UNSET", faas.name=~".-lambda."}

PIPE OPERATORS — chain after query with "|": | copy src_field AS dst_field — copy field value | drop field1, field2 — remove fields from output | extract_regexp "(?Pregex)" — extract fields via named capture groups | join by (field) (...subquery...) — join with subquery results | keep field1, field2 — keep only specified fields | limit N — return at most N results | math result = field1 + field2 — compute derived fields (+, -, *, /, %) | rename src AS dst — rename a field | replace (field, "old", "new") — replace substring in field | replace_regexp (field, "re", "replacement") — regex replacement | sort by (field) [asc|desc] — sort results | stats as alias [by (group_fields)] — aggregate results | unpack_json — extract fields from JSON log body

STATS FUNCTIONS (use with | stats pipe): avg(field) — arithmetic mean count() — total number of matching entries count_empty(field) — count entries where field is empty count_uniq(field) — count distinct values max(field) — maximum value median(field) — median (50th percentile) min(field) — minimum value quantile(p, field) — p-th quantile (e.g., quantile(0.95, duration)) sum(field) — sum of values

Example queries:

  • All logs (discover structure): *

  • Lambda logs: {faas.name="webhook-lambda-prod"}

  • Search errors: {faas.name=~".*"} AND "error"

  • By environment: {env="production"}

  • Count errors per function: {faas.name=~".*"} AND "error" | stats count() as error_count by (faas.name)

  • Top 10 slowest: {service_name="my-service"} | sort by (duration) desc | limit 10

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>",
      "start": "<start>",
      "end": "<end>"
    },
    "name": "query_logs"
  }
}

Input Schema

NameRequiredDescriptionDefault
endYesEnd time in RFC3339 format or Unix timestamp in seconds
limitNoMaximum log entries to return (default: 100)
queryYesThe log search query including stream filters (LogsQL syntax)
startYesStart time in RFC3339 format (e.g., 2024-01-01T00:00:00Z) or Unix timestamp in seconds

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.1

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are supplied, so the description carries the full disclosure burden, and it does substantial work: labels vary by source, not every source has service_name, and results should be checked via the _stream field. It does not state read-only status, retention/time-range bounds, result caps beyond the limit parameter, or pagination behavior, which are the remaining gaps for a no-annotation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Long but deliberately structured: purpose first, then a front-loaded 'IMPORTANT' discovery caveat, then syntax, pipe operators, stats functions and worked examples. Given that the agent must author a domain-specific query language to use the tool at all, each block is load-bearing; a few example labels duplicate the earlier label list but the redundancy is minor.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description covers query authoring exhaustively, including how to inspect returned structure via _stream. The weak spot is the return value: 'Returns log entries matching the query' never indicates entry shape, truncation, or how limit interacts with time-range size.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds real meaning for the 'query' parameter by documenting LogsQL stream-filter syntax, negation, regex matching, pipe operators and stats functions – none of which the schema conveys. Start/end/limit get nothing beyond their schema text, which keeps this from a 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource+backend: 'Query logs from CubeAPM using LogsQL syntax (VictoriaLogs compatible).' The resource (log entries) is clearly distinct from the metrics and trace siblings, so an agent can pick this tool without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit operational rule for first use ('use "*" query first to discover available labels') plus source-specific label conventions and a concrete example set. It stops short of stating when to prefer this over get_trace or search_traces, so the sibling-routing half of the guidance is absent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.