How do I line up alerts from Prometheus with Prometheus metrics on one timeline?
In Tares, you ingest your Prometheus metrics and your Prometheus alerts as two sources that carry the same service label. Tares then merges both on one clock for that service in Explore. The alert shows what fired, and the metric shows how it got there.
How it works
Two connectors read from the same Prometheus server, and the shared service label joins them.
- The Prometheus metrics connector turns each series you pick into a metric event on every poll tick. You choose metrics by name or by a label they carry, and you write no PromQL. The value is stored as a number-typed
valuelabel. - The Prometheus alerts connector polls Prometheus’s own alert list, the alerts your alerting rules have already fired. It makes one event per active alert and a
resolvedevent when the alert clears. It needs no Alertmanager. - Alert state is tracked across polls, so each alert fires once and re-emits only on a state change. You do not get one copy per tick.
- Each alert event has the alert name as its
event_type, its summary astext, its labels as Tares labels, and astateoffiring,pendingorresolved.
Because both sources are keyed by the same service label, Tares builds one timeline per service. The AI SRE guide builds exactly this with a metrics source, a logs source and an alerts source, all keyed by service.
Set it up
-
Start Tares and open the console at
http://127.0.0.1:8787.tares up -
Add the metrics source. Go to Sources → Add source → Prometheus, enter the
urland any auth, and click Discover. Pick metrics by name (a metric name or aprefix_*pattern) or by label. Tares proposes the entity key and labels from a sample. You can also ask a connected agent: “Use tares to ingest thepg_*metrics from the Prometheus atlocalhost:9090.” The generated config looks like this:- name: metrics connector: prometheus poll: 10s config: url: http://localhost:9090 queries: - promql: '{__name__=~"(pg_stat_database_xact_commit|pg_up)"}' # generated from your picks by_name: true labels: - { name: service, field: metric.service, primary: true } - { name: value, field: value, type: number } # the metric value, aggregate it in triggers -
Add the alerts source. Go to Sources → Add source → Prometheus alerts, enter the same
url, and click Discover. It lists your alerting rules and their severities. Optionally filter by severity (blank means all) and toggle include pending.- 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 } -
Give the alerts the same key as the metrics. Discover only proposes the labels every alert has,
severityandstate. An alert’s dynamic labels such asnamespaceorserviceexist only while it fires. Once real alerts have been ingested, open the source’s Fields tab and promoteserviceso it matches the label on your metrics source. -
Open Explore and pick the service. The metric events and the alert events appear merged on one clock.
You can also create either source with POST /api/sources using the same object.
What you get
- One timeline per service, with the metric points and the alert events interleaved in time order.
- The alert that fired and the metric that tripped it side by side, so you see the climb before the alert and the
resolvedevent when it clears. - A numeric
valueon every metric event, so a trigger over the same service can aggregate it withmax,avgorsum. - Prometheus keeps owning alerting. Tares ingests what fired, correlates it with the evidence and can dispatch it to an agent. Nothing is re-thresholded.
- A quick check that it works. In each source, Recent events shows one event per series per poll for metrics, and one event per active alert for alerts. Fields shows the labels each event carries, including
metric.serviceand the numericvalue.
The same read is what a connected agent works from, so an investigation starts from the correlated timeline rather than from separate queries.
When something else fits
- If your alerts already route through Alertmanager and you prefer to keep that path, use the Alertmanager connector instead of polling Prometheus for alerts. It receives the alerts through a webhook receiver pointed at a Tares ingest URL. The metrics source works the same way beside it.
- If you want a derived value rather than a raw series, such as a rate or a p99, a
queriesrow on the metrics source can hold a single PromQL expression with an explicitevent_typeandfield. The pick-metrics flow covers raw ingestion without any PromQL. - If a root cause is usually a change, add deploys and config changes as a webhook source keyed by the same
servicelabel, so they land on the same timeline. The AI SRE guide shows how.