How do I test alerts from Prometheus about failed deploys before a real incident?
Tares lets you rehearse failed-deploy alerts before an incident by creating a prometheus_alerts source and checking Recent events and Fields on the source page. Make a deploy alert fire in Prometheus and you see the event, its labels and its state in minutes. If your alerts reach Tares through Alertmanager, post a sample batch to the ingest URL of an Alertmanager source and read the same two views.
How it works
The prometheus_alerts connector polls Prometheus’s own alerts endpoint, every 30 seconds by default. Prometheus decides what counts as an alert, and Tares records each active alert as an event.
- Each event has
event_typeset to the alert name,textset to the alert’s summary, and the alert’s labels as Tares labels. Tares adds astatelabel that isfiring,pendingorresolved. - State is tracked across polls. An alert fires once and emits a
resolvedevent when it clears. You do not get one copy per poll. - Discover lists your configured alerting rules and the severities present, so you can confirm Tares sees your deploy rules before anything fires.
- Discover proposes only the labels guaranteed to exist,
severityandstate. Labels such asnamespaceorserviceexist only while an alert is firing, so you add them from the Fields tab once a real or test alert has been ingested.
Because this connector polls, it has no ingest URL. Posting a sample payload to an ingest URL is a push-source technique, and it applies when you receive alerts through the Alertmanager connector or the webhook connector. For a push source, test_source takes no payload and only returns the ingest endpoint, so it does not check your label mapping. Post a sample and read the source page instead.
Set it up
- Create the source. Ask a connected agent: “Use tares to ingest the firing alerts from the Prometheus at
localhost:9090.” The agent callsdiscover_source, thencreate_source. Or go to Sources → Add source → Prometheus alerts, enter theurland any auth, and click Discover. Check that your failed-deploy rules appear in the list. - Pick what to ingest. Set severity to the levels your deploy alerts use, or leave it blank for all. Turn on include pending to see an alert while it waits out its
for:duration, which shows you the first sign of a failed deploy earlier. The source looks like this:
- 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 }- Make a deploy alert fire in Prometheus, the way a failed deploy would. Wait one poll interval.
- Open the source and check Recent events. You should see one event for the alert, with the alert name as the event type, its summary as the text and
stateset tofiring. When the alert clears, aresolvedevent appears. - Open Fields. It shows the labels the alert carries. Promote the ones you correlate on, such as
namespaceorservice, so a real incident groups with the right service. - If you route deploy alerts through Alertmanager, rehearse that path with its own source. Create one under Sources → Add source → Alertmanager alerts, copy its ingest URL, and post a sample batch:
curl -X POST http://localhost:8787/ingest/<ingest_key> \
-H 'Content-Type: application/json' \
-d '{"alerts":[{"status":"firing","labels":{"alertname":"PostgresDown","severity":"critical","namespace":"prod"},"annotations":{"summary":"Postgres is down"},"startsAt":"2024-01-01T00:00:00Z"}]}'- Read Recent events and Fields on the Alertmanager source. The event type is the alert name, the text is the summary, and the labels include a
statusoffiringorresolved. Swap in your own alert name, labels and summary to see how your deploy alert maps. This checks the Alertmanager source only. Theprometheus_alertssource maps alerts by its own declared labels, so confirm it with step 4.
What you get
- Proof that Tares sees your deploy alerting rules before an incident, from Discover and from a test alert in Recent events.
- The exact event type, text and labels a failed-deploy alert produces, including the
statevalue. - A confirmed set of correlation labels, such as
namespaceorservice, promoted from Fields. - Confirmation that a firing alert emits one event, and that a
resolvedevent follows when it clears. - For an Alertmanager route, a tested ingest URL and a view of how a sample batch is split into one event per alert.
When something else fits
- Use the Alertmanager connector instead if you want Alertmanager’s grouping, silencing and resolved handling with real-time delivery. Its ingest URL also lets you post sample batches whenever you like.
- Use the webhook connector if the deploy failure comes from a CI system or another sender that can POST JSON, and map the payload fields with labels.
- Stay with
prometheus_alertsif you have no Alertmanager and want Prometheus to stay the one place that decides what is an alert. For the wider picture, see AI SRE and the Prometheus alerts connector page.