How do I use Claude Code to investigate alerts from Prometheus with Tares?
Connect Claude Code to Tares over MCP, ingest your Prometheus alerts, and ask about the service that alerted to get the alert and its evidence in one timeline. Tares polls the alerts your Prometheus rules fire and correlates them with your other sources by label. Claude Code calls the Tares read tool and answers from that merged timeline instead of from the alert alone.
How it works
- The
prometheus_alertsconnector polls Prometheus’s own alerts endpoint every 30 seconds by default. Prometheus keeps deciding what counts as an alert. You need no Alertmanager and no PromQL. See Prometheus alerts. - Each active alert becomes one event. The
event_typeis the alert name, the text is its summary, and the alert’s labels become Tares labels, plus astateoffiring,pendingorresolved. - Tares tracks state across polls. An alert fires once, re-emits only when its state changes, and produces a
resolvedevent when it clears. - When your alert source and your metrics and log sources share a label such as
service, they form one timeline per service. - Claude Code connects over MCP and discovers the Tares tools. Its
readtool returns a time-ordered timeline across all sources that match a label selector, such asserviceequal toapi-server. - Findings join the same timeline. Claude Code can read earlier findings with
list_findingsand write its own conclusion withrecord_findingorremember, so the next investigation starts from it.
For the wider picture of metrics, logs, alerts, triggers and agents, see Build an AI SRE.
Set it up
-
Install Tares and start it. The daemon listens on port 8787.
uv tool install tares # or: brew install glassflow/tap/tares tares up -
Add the alerts source. In the console, go to Sources, then Add source, then Prometheus alerts, enter the Prometheus
urland click Discover. You can also ask a connected agent to do it. The YAML form is:- name: alerts connector: prometheus_alerts poll: 30s config: url: http://localhost:9090 severities: critical,warning # blank = all labels: - { name: severity, field: labels.severity, primary: true } - { name: state, field: state } -
Once real alerts have been ingested, open the source’s Fields tab and promote per-alert labels such as
namespaceorservice. Use the same label name your metric and log sources use, so the alert lands on the same timeline as its evidence. -
Start the MCP server in a second shell. The daemon alone does not serve
/mcp.tares mcpThe endpoint is
http://127.0.0.1:8788/mcp. On your own server or Tares Cloud, the MCP server is already running. Use your own endpoint, shown under Connect in the Tares Cloud console. -
Connect Claude Code. The Tares plugin is the default path. It wires the MCP read-back and session capture in one install, and it asks for the Tares URL, an optional auth token and a capture toggle.
/plugin marketplace add glassflow/tares /plugin install tares@taresTo connect without capturing sessions, add Tares as an HTTP MCP server with the claude CLI. The connecting agents page lists the exact command, and the console’s Connect page fills in your endpoint and token. On a secured instance, use an API key with the
readscope. -
Verify the connection by asking Claude Code:
Use tares: what are you ingesting right now?
It calls
catalog_listand answers with your sources, triggers and projects. -
Investigate. Ask about the service that alerted:
Use tares: what happened to api-server in the last 15 minutes?
Claude Code calls
readwith theservicelabel set toapi-serverand answers from the merged timeline of alerts, metrics and logs.
What you get
- An answer that reads the alert together with the evidence around it, in one time-ordered read, instead of an alert name with no context.
- One event per active alert, plus a
resolvedevent when it clears, so you can see when a problem started and when it ended. - Alerts that stay where they are. Prometheus keeps owning alerting, and Tares ingests what fired and correlates it.
- An investigation that carries forward. Findings Claude Code records appear on the timeline, so the next question starts from the previous conclusion.
- Visibility into the reads. In the console, Reads lists each read as it happens, tagged
client = mcp.
When something else fits
- If you already route alerts through Alertmanager, use the
alertmanagerconnector. It receives what a webhook receiver pushes to a Tares ingest URL, and you keep your routing as it is. The AI SRE guide compares it with this connector. - If you want nobody to ask at all, use a trigger. A trigger can wake a Tares agent when an alert event arrives, and the agent writes a finding before you open the console. The same guide walks through this end to end.
- If you use Cursor, Codex or another MCP client instead of Claude Code, the steps are the same apart from the client config. See connecting agents for each client’s setup.
- If your alerts do not come from Prometheus rules, add the source that matches where they come from and keep the shared
servicelabel.