How do I test Alertmanager alert groups about a cron job that stopped before a real incident?
Tares lets you test Alertmanager alert groups before a real incident by posting a sample batch to the source’s ingest URL and reading the result under Recent events. Create an Alertmanager source, send the batch with curl, then check the event and the labels it carries. The same ingest URL goes into your Alertmanager receiver once the test looks right.
How it works
The alertmanager connector is a push receiver. Alertmanager POSTs a batch shaped like { alerts: [...], ... } to the source’s ingest endpoint, and Tares turns each entry in the alerts array into its own event:
event_typeis the alert name.textis the alert’s summary.- The alert’s labels become Tares labels, plus a synthetic
statuslabel that isfiringorresolved. - The full alert, including
fingerprint, stays in the payload.
The entity key comes from a label automatically, in this order: namespace, service, job, instance. A label you mark primary takes precedence. If your cron alerts carry a different label that identifies the job, set the advanced key_label field to it.
For a push source, test_source takes no payload and only returns the ingest endpoint. It does not check your label mapping. To check the mapping, post a sample payload yourself and read Recent events and Fields on the source page. The webhook connector works the same way if you would rather send cron results from the job itself.
Set it up
- Create the source. Ask a connected agent: “Use tares to create an Alertmanager source and give me the webhook URL.” Or open Sources → Add source → Alertmanager alerts, name it and select Create. Either way you get an ingest URL of the form
/ingest/<ingest_key>. - Post a sample batch to that URL. This is the example from the Alertmanager connector page:
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"}]}'- Make it describe your cron job. Replace the
alertnamevalue, thesummarytext and the labels with the ones your cron alert rule produces. Use the same label names your real alert uses, so the test exercises the mapping you will rely on. Send a second batch withstatusset toresolvedto see how a resolved alert arrives. - Open the source page and check Recent events. Confirm the
event_typematches your alert name, thetextshows the summary, and the labels andstatusare what you expect. - Open Fields. It shows the alert labels, so you can promote a label such as
namespaceorserviceto correlate on. - When the mapping looks right, add the receiver to your
alertmanager.ymland reload Alertmanager:
receivers:
- name: tares
webhook_configs:
- url: http://localhost:8787/ingest/<ingest_key>
send_resolved: true
route:
receiver: tares- If your instance runs with auth on (
tares up --auth), the sender uses a Bearer Authorization header holding an ingest-scoped API key. The source page shows the auth block in its copy-paste receiver. Without auth, no key is needed.
For the wider picture of how sources feed investigations, see AI SRE.
What you get
- A way to check your Alertmanager wiring and label mapping before a cron job actually stops.
- Events under Recent events that show the alert name, summary, labels and
statusfor the batch you sent. - A Fields view of the alert labels, so you choose the key to correlate on from labels you have seen arrive.
- A tested ingest URL and receiver block you can reuse in
alertmanager.ymlwithsend_resolved: true, so firing and resolved alerts both reach Tares.
When something else fits
- If the cron job reports its own result and you do not route it through Alertmanager, post JSON straight to a source with the webhook connector, where you declare the labels yourself.
- If you want Prometheus alerts without Alertmanager’s grouping and silencing, the
prometheus_alertsconnector polls them instead.