Skip to main content
Glama
AIops-tools

observability-aiops

alert_log_context

Read-only

Correlate a firing Prometheus alert to Loki log streams by mapping alert labels into a LogQL selector and fetching matching error logs for root-cause analysis.

Instructions

[READ][cross-signal] Correlate a firing Prometheus alert to its Loki log streams.

Reads the firing alert's labels from the Prometheus target, maps the Loki-friendly ones (namespace, job, service, app, container, pod, instance, component — first four, in that priority order) into a LogQL stream selector, and pulls the correlated error streams from the Loki target. Best-effort: label values are escaped into the selector and only labels the alert and Loki actually share will match.

Args: alertname: The firing alert's name (from firing_alerts / firing_alert_rca). hours: Lookback window in hours (capped at the tool's max lookback). target: Prometheus target name from config; omit for the default. loki_target: Loki target name from config; omit for the default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hoursNo
targetNo
alertnameYes
loki_targetNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.7.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only declare readOnlyHint=true, and the description adds substantial mechanism beyond that: it reads the alert's labels, maps Loki-friendly labels in a stated priority order, escapes values into a LogQL selector, matches only shared labels, and caps lookback. It also states what it returns (correlated error streams). This is rich behavioral disclosure well past the annotation bar.

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?

Front-loads the [READ][cross-signal] tag and the purpose sentence, then mechanism, then Args — a sensible order. It runs a bit long with the parenthetical label list and escaping detail, but nearly every sentence adds real information, so it stays efficient.

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?

With no output schema, the description does sketch the return ('correlated error streams') and covers all inputs and the best-effort caveat, so an agent can call it correctly. It stops short of detailing the shape of the returned streams, which is the only real gap against the tool's complexity.

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

Parameters5/5

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

Schema coverage is 0%, so the description must carry the burden, and it does: an Args section documents all four parameters — alertname (and its source), hours (lookback, capped), target (config name, omit for default), and loki_target (config name, omit for default). This fully compensates for the empty schema descriptions.

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?

States a specific verb and resource: correlate a firing Prometheus alert to its Loki log streams. The [cross-signal] tag plus the explicit Prometheus-to-Loki bridge clearly distinguishes it from single-signal siblings like loki_query, firing_alert_rca, or instant_query. An agent can pick it 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?

Provides clear context for use (a *firing* alert) and routes the agent to the right source for the input by naming 'firing_alerts / firing_alert_rca'. It also sets 'Best-effort' expectations. However, it gives no explicit when-not-to-use condition or a named alternative to reach for when correlation fails.

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