What should Grafana alert rules about a cron job that stopped include for an AI SRE?
Grafana alert rules about a stopped cron job should set a service label, a severity label and a summary annotation, so Tares can tie the alert to evidence. Tares keys each event on the service label, which lets your agent line the alert up with that service’s metrics, logs and deploys. The start time comes with every alert Grafana sends, so you do not have to add it.
How it works
Grafana Alerting reaches Tares through the webhook connector and a Grafana contact point. Tares has no connector of its own for Grafana Alerting today.
- Grafana posts one notification per group of alerts. Tares stores it as one event and keeps the whole payload lossless, including the alerts list.
- Each alert in that list carries its labels, its annotations,
startsAt,endsAtand afingerprint. Your agent can read the summary annotation and the start time from there. - Top-level fields such as
status,receiverandtitlework for labels and fortext_template. commonLabelsholds only the labels shared by every alert in the notification. ForcommonLabels.serviceto be filled, every alert rule must set aservicelabel, and the notification policy must group alerts byservice. Then each notification covers one service.
The service label is what places the event on a service’s timeline. If your metrics, logs and deploy sources use the same service label with the same values, the cron job alert appears next to that evidence. This is the per-service timeline described in Build an AI SRE.
Set it up
- In each Grafana alert rule for a cron job, set these labels and annotations:
- Label
service: the name of the service that owns the job, spelled exactly as in your other Tares sources. - Label
severity: for example critical or warning. - Annotation
summary: a plain sentence that says which job stopped and what it was expected to do, for example that the nightly invoice job has not run. - The start time needs no setup. Grafana sends
startsAtfor every alert.
- Label
- In the notification policy that handles these rules, group alerts by
service. - In Tares, go to Sources → Add source → webhook and create a source like this. The
servicelabel is primary:
- name: grafana-alerts
connector: webhook
config:
text_template: '{status}: {title}'
labels:
- { name: service, field: commonLabels.service, primary: true }
- { name: severity, field: commonLabels.severity }
- { name: status, field: status }- Copy the ingest endpoint from the source page. In Grafana, add a Webhook contact point with that URL and the POST method.
- When Tares has auth on, set the contact point’s Authorization header scheme to Bearer and the credentials to an ingest-scoped API key.
- Route the cron job alerts to the contact point from the notification policy.
- Check the mapping by posting a sample notification, then open Recent events and Fields on the source page:
curl -X POST http://localhost:8787/ingest/<ingest_key> \
-H 'Content-Type: application/json' \
-d '{"status":"firing","title":"Nightly invoice job stopped","commonLabels":{"service":"billing","severity":"critical"}}'See the webhook connector page for the full set of options.
What you get
- Every stopped-cron notification lands as one event on the timeline of the service named in the
servicelabel. - The event text reads from
statusandtitle, so a firing alert and its resolved notice are easy to tell apart. - The severity is available as a label on the event.
- The full payload stays intact, so your agent can read the summary annotation and
startsAtfor each alert and compare that start time with the last good log lines, metrics and deploys on the same timeline. - When the alert and your other sources share the
servicelabel, the agent reads one correlated view and can tie the stopped job to a specific change or error instead of guessing.
When something else fits
- If you want one Tares event per alert instead of one per notification, create a separate alertmanager source with its own ingest URL. Grafana’s default payload is Alertmanager compatible, so it can take the same notifications.
- If your policy cannot group by service, so one notification mixes several services,
commonLabels.servicewill be empty for the services that differ. Group byservicefirst, or use the alertmanager source.