Which Prometheus metrics show 5xx errors on an API?
Tares ingests the Prometheus metrics your API exposes for 5xx responses, picked by name or by a label they carry, with no PromQL to write. Each series becomes an event with a number-typed value label. A trigger can filter to one metric and aggregate that value. Which metric names show 5xx depends on what your API exports, and Tares lists them for you to pick.
How it works
Tares does not ship a fixed list of 5xx metric names. Your API and its exporter decide the names, and the Prometheus connector discovers them on your server.
- Discovery. Given the Prometheus
url, Tares lists the server’s metrics and labels for you to pick from. - Pick by name. Type a metric name or a
prefix_*pattern and tick the matches. If your API prefixes its error metrics, a pattern finds them in one step. - Pick by label. Pick a label, such as the one your API uses for the response code. Tares lists the metrics that carry it, and you tick the ones that show 5xx errors.
- One event per series per poll. Your picks compile to a single selector, and each event is named by its own metric name.
- A number you can aggregate. The metric value is stored as a number-typed
valuelabel, so a trigger can usemax,avgorsumon it.
To narrow the metrics you ingest, the exclude option on a query entry drops metrics by substring in the name, for example _bucket.
This fits into the wider AI SRE workflow: the 5xx series are joinable with logs, deploys and alerts on the same key.
Set it up
-
Start Tares locally.
tares up -
Ask a connected agent to do the discovery for you:
Use tares to ingest the metrics from the Prometheus at
localhost:9090that show 5xx errors on my API.The agent calls
discover_sourceto list the metrics and labels,test_sourcefor one poll, thencreate_source. You name the metrics. It never writes PromQL. -
Or use the console. Open Sources → Add source → Prometheus, enter the
url(plus any auth) and choose Discover. Pick by name or by label, tick the metrics that carry your 5xx counts, and confirm. Tares proposes the entity key and labels from a sample. -
Check the generated config. It looks like this, with your own metric names in the selector:
- name: metrics connector: prometheus poll: 10s config: url: http://localhost:9090 queries: - promql: '{__name__=~"(your_5xx_metric)"}' # 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 triggersYou can also
POST /api/sourceswith the same object. -
Verify. Open the source. Recent events shows one event per series per poll, and Fields shows the labels (
metric.service, and any others your picks carry) and the numericvalue. Watch the metric move in Explore by picking the entity the series is keyed on. -
Add a trigger that aggregates the value. Filter it to one metric by
event_type, then aggregatevalue:- name: api-5xx sources: [metrics] filters: - { field: event_type, op: eq, value: your_5xx_metric } condition: { aggregate: max, field: value, predicate: "> your_limit", window: 5m }Replace
your_5xx_metricwith the metric name you picked andyour_limitwith the number that counts as too many errors for your API.
What you get
- A metric event for each 5xx series on every poll, named by its own metric name.
- A number-typed
valuelabel that triggers can aggregate withmax,avgorsum. - A trigger scoped to one metric through its
event_type, so other metrics in the same source do not count toward the condition. - Events keyed on the same entity as your logs, deploys and alerts, so you can line up a spike in errors with what changed.
- A config that the console or agent generates, so you do not hand-write selectors.
When something else fits
- If you want a computed metric, such as a derived rate or a
histogram_quantile, aqueriesrow can hold a single PromQL expression with an explicitevent_typeandfield. This is the advanced escape hatch. - If your API exports OpenTelemetry metrics instead of exposing them to Prometheus, use the OTLP connector. It receives logs, traces and metrics, and
service.namebecomes theservicelabel.