Skip to main content
Glama
mackerelio-labs

Mackerel MCP Server

Official

Search Logs

search_logs
Read-only

Search a service's application logs in Mackerel to investigate errors and incidents, find logs by trace ID, keyword, severity, or JSON body fields, and page through results within a time range.

Instructions

Search logs of a service from Mackerel.

šŸ” USE THIS TOOL WHEN USERS:

  • Investigate errors or incidents by reading application logs

  • Find logs related to a specific trace (traceId)

  • Look for logs containing specific keywords or matching structured (JSON) body fields

šŸ“ KEEPING RESPONSES SMALL:

  • Pass serviceNamespace when the service has one. Without it, only services without a namespace are searched

  • Omit from / to to search relative to the current time (lookbackMinutes, default 60). The response includes the actual timeRange searched

  • Narrow the time range and use severities / keywords / bodyAttributes filters first

  • By default only timestamp, severity, body, traceId and spanId are returned. Use fields to request attributes only when needed

  • Log bodies longer than maxBodyLength are truncated and marked with bodyTruncated: true

  • To get more logs, pass pagination.nextPageCursor as pageCursor as-is with the same filters. The cursor carries the time range and sort order, so from / to / order are not needed. The API allows 1 request per second

Logs in the last 15 minutes

search_logs(serviceName="my-service", serviceNamespace="my-namespace", lookbackMinutes=15)
search_logs(serviceName="my-service", serviceNamespace="my-namespace", from=1700000000, to=1700003600, traceId="0af7651916cd43dd8448eb211c80319c", order="ASC")
search_logs(serviceName="my-service", serviceNamespace="my-namespace", from=1700000000, to=1700003600, keywords=["timeout", "payment"])

Filter JSON bodies: {"res": {"status": 500+}}

search_logs(
  serviceName="my-service",
  serviceNamespace="my-namespace",
  from=1700000000,
  to=1700003600,
  bodyAttributes=[{keyPath: ["res", "status"], value: "500", type: "int", operator: "GTE"}]
)

Include log attributes

search_logs(serviceName="my-service", serviceNamespace="my-namespace", from=1700000000, to=1700003600, fields=["timestamp", "body", "attributes", "resourceAttributes"])

Next page

search_logs(serviceName="my-service", serviceNamespace="my-namespace", severities=["ERROR"], pageCursor=<pagination.nextPageCursor>)

Input Schema

NameRequiredDescriptionDefault
toNoEnd time (Unix epoch seconds, exclusive). Defaults to the current time. The range from `from` must be 30 days or less
fromNoStart time (Unix epoch seconds, inclusive). Defaults to `lookbackMinutes` before `to`
orderNoSort order by timestamp. Default is DESC (newest first)
fieldsNoFields to include for each log. Default is ["timestamp","severity","body","traceId","spanId"]. Attribute fields are returned as {key: value} objects
perPageNoNumber of logs per page (1-1000). Default is 20
traceIdNoOnly logs associated with this trace ID (32-digit hex)
keywordsNoKeywords that must all appear in the log body (partial match, AND)
pageCursorNoPass `pagination.nextPageCursor` or `pagination.previousPageCursor` from a previous response as-is. The cursor carries the time range and sort order, so `from`, `to`, `lookbackMinutes` and `order` are ignored. Keep the filters unchanged between pages
severitiesNoSeverities to include (OR)
serviceNameYesService name
maxBodyLengthNoTruncate each log body to this many characters (default 1000). Truncated logs have `bodyTruncated: true`
bodyAttributesNoFilters on fields of JSON log bodies (AND). Logs whose body is not JSON never match
lookbackMinutesNoWhen `from` is omitted, search this many minutes before `to` (default 60). Use this for relative ranges such as 'the last 15 minutes' without knowing the current time
serviceNamespaceNoService namespace. Corresponds to `service.namespace` in OpenTelemetry semantic conventions. When omitted, only services without a namespace are searched, so always pass it for services that have one

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.10.0

TDQS

A4.3/5.0
Behavior5/5

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

Despite readOnlyHint already declaring the safety profile, the description discloses a lot beyond annotations: a documented 1 request/second rate limit, default returned fields, body truncation with a bodyTruncated marker, and that the response echoes the actual timeRange searched. The cursor contract — that it carries time range and sort order so from/to/order are ignored and filters must stay fixed — is exactly the kind of non-obvious behavior an agent cannot get from the schema alone.

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

Conciseness4/5

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

Purpose is front-loaded, the use-case and response-size sections are scannable, and nothing is padded with filler. Seven worked examples for a 14-parameter tool with nested objects is defensible, though a couple (e.g. the plain keyword and time-range cases) partially duplicate the schema descriptions.

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

Completeness5/5

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

For a 14-parameter read tool with nested bodyAttributes and no output schema, the description supplies the missing return-side information — default field set, truncation behavior, and the pagination.nextPageCursor/previousPageCursor contract — so an agent can both call and paginate it correctly without further context.

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 3 is the floor, but the description adds real semantics on top: serviceNamespace omission silently narrows the search to namespace-less services, from/to omission falls back to lookbackMinutes, and pageCursor must be passed through as-is. The examples also demonstrate non-obvious parameter shapes like bodyAttributes keyPath/operator combinations.

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

Purpose4/5

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

States a specific verb and resource ('Search logs of a service from Mackerel') and enumerates three concrete investigative use cases. It never differentiates itself from sibling tools that also surface logs or traces (get_alert_logs, get_trace, list_traces), so an agent deciding between those must infer the boundary.

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?

The 'USE THIS TOOL WHEN USERS' block gives clear triggering contexts (error investigation, trace lookup, keyword/structured-body matching), and the response-size section establishes a recommended filter ordering. There is no explicit when-not-to-use guidance and no sibling named as an alternative, which keeps it short of a 5.

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