How do I wake an AI SRE once when Alertmanager alert groups report a cron job that stopped?
Tares wakes your AI SRE once per stopped cron job when you pair the alertmanager connector with a trigger that has a cooldown. Each alert Alertmanager sends becomes one event, and the trigger’s cooldown allows one firing per entity in that gap. Resolved alerts are still recorded on the entity’s timeline with a status of resolved.
How it works
The pieces fit together like this:
- Alertmanager sends batches. You point a
webhook_configsreceiver at the ingest URL of an alertmanager source. Tares fans out thealertsarray into one event per alert. Theevent_typeis the alert name, thetextis the summary, and the alert labels become Tares labels plus a syntheticstatusoffiringorresolved. The full alert, including itsfingerprint, stays in the payload. - Each alert gets an entity key. Tares derives it from a label, in the order
namespace,service,job,instance, or from a label you declareprimary. To key on something else, setkey_labelon the source. For a cron job, make sure the key names the job, so each job is its own entity. - The trigger watches the source. It checks its condition as events arrive, and
group_by: [key_value]evaluates it per entity. - The cooldown holds repeats back.
cooldownis the minimum gap between firings for the same entity. A repeating alert for the same stopped cron job fires one investigation, and a different job still fires on its own. - The agent gets context. When the trigger fires, Tares POSTs a dispatch to each subscriber. Its
payloadis the entity’s correlated timeline across the trigger’s sources overcontext_window, so the agent starts with the evidence already in hand.
For the wider picture of how agents investigate, see AI SRE.
Set it up
-
Create the source. In Sources → Add source → Alertmanager alerts, name it and Create. Or ask a connected agent: “Use tares to create an Alertmanager source and give me the webhook URL.”
-
Add the receiver to
alertmanager.ymland reload Alertmanager. Keepsend_resolved: trueso resolved alerts reach Tares too:
receivers:
- name: tares
webhook_configs:
- url: http://localhost:8787/ingest/<ingest_key>
send_resolved: true
route:
receiver: tares-
Add authentication if Tares has auth on. The sender uses a Bearer Authorization header holding an ingest-scoped API key, set under
http_configin thewebhook_configsentry. It is needed only on a secured instance (tares up --auth). -
Check the pipeline. Send a test batch, then look at Recent events:
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"}]}'Fields shows the alert labels, so you can promote the one that names your cron job and correlate on it.
- Define the trigger. Add it under Triggers → Add trigger or in the catalog YAML. Replace the source name and the alert name (
CronJobStoppedhere) with yours:
triggers:
- name: cron_stopped
sources: [cron-alerts]
filters:
- { field: event_type, op: eq, value: CronJobStopped }
- { field: status, op: eq, value: firing }
condition:
aggregate: count
predicate: "> 0"
window: 5m
group_by: [key_value]
emit:
kind: cron_stopped
context_window: 15m
cooldown: 1h- Subscribe the agent. A Tares agent wakes when a project wires it to the trigger and you turn it on there. An external agent calls
subscribe(trigger, url)over MCP, or registers withPOST /subscribe. Your endpoint must answer with a 2xx and should dedupe ondispatch_id, because delivery is at-least-once.
The Alertmanager connector page covers the receiver and key_label in full. The triggers guide covers conditions, subscriptions and delivery.
What you get
- One investigation per stopped cron job within the cooldown, however many times Alertmanager repeats the alert.
- Independent firing per job, because the condition and the cooldown work per entity.
- A dispatch whose payload is the correlated timeline over
context_window, so the agent does not need a follow-up call. - A record of every firing, even with zero subscribers, under Firings in the console, on the trigger’s own page and on the project’s Activity. Each dispatch has a page with the delivery outcome and the exact payload sent.
- Resolved alerts recorded as events with
statusset toresolved, so the timeline shows when the job came back. The status filter in step 5 keeps them from counting toward a firing. Filters also narrow which events are handed over, so a firing-only filter keeps resolved events out of the dispatch payload. They stay recorded on the source, and you see them in Recent events. To hand resolved events to the agent as well, drop the status filter. A resolved event then counts toward the condition like any other event.
When something else fits
- If you want a trigger to fire on a metric threshold instead of an alert, use a metrics source and a numeric condition as in the triggers guide.
- If you need Prometheus alerts without running Alertmanager, the
prometheus_alertsconnector polls them, but it does not give you Alertmanager’s grouping, silencing and real-time delivery. - If you want a periodic look at the cron alerts rather than a wake-up on each one, give the trigger a schedule with
condition: {every: 10m}.