How do I test PagerDuty incidents about a cron job that stopped before a real incident?
Tares lets you test PagerDuty incidents about a stopped cron job by posting a sample payload to the source’s ingest URL, then checking Recent events and Fields on the source page. PagerDuty reaches Tares through the webhook connector and a PagerDuty setup, and Tares has no connector of its own for PagerDuty today. Because test_source on a push source only returns the ingest endpoint, the sample post is what checks your label mapping.
How it works
- PagerDuty v3 webhook subscriptions deliver JSON shaped like
{"event": {"id": "...", "event_type": "incident.triggered", "resource_type": "incident", ...}}to the Tares ingest URL. - A webhook source stores the whole payload lossless and maps the fields you declare as labels.
- Label fields can be one-level dotted paths such as
event.event_type. The event type field setting reads top-level fields only, so you set a fixedevent_typeinstead. - Key the source on a
servicelabel with aconstvalue that names the cron job, and mark itprimary. Every incident then carries that service as its key, and incident types do not collapse into one key. - Keep the PagerDuty event type in a separate, non-primary label named
incident_event. Do not name a labelevent_type, because the event type column shadows it in trigger filters. - When Tares has auth on, the sender uses a Bearer Authorization header holding an ingest-scoped API key. Do not set
signature_schemefor PagerDuty. Its signed header carries av1=prefix thathmac_sha256does not accept, so the Bearer header is the credential.
Set it up
- Create the source under Sources → Add source → webhook, or ask a connected agent to create a webhook source for your PagerDuty incidents. Use this config, replacing the
constvalue with a name for your cron job:
- name: pagerduty-cron
connector: webhook
config:
event_type: pagerduty_incident
labels:
- { name: service, const: nightly-backup-cron, primary: true }
- { name: incident_event, field: event.event_type }
- { name: resource_type, field: event.resource_type }- Copy the ingest endpoint from the source page. Calling
test_sourcereturns only that endpoint, so it does not check the mapping. - Post a sample
incident.triggeredpayload that looks like what PagerDuty sends:
curl -X POST http://localhost:8787/ingest/<ingest_key> \
-H 'Content-Type: application/json' \
-d '{"event": {"id": "TEST1", "event_type": "incident.triggered", "resource_type": "incident", "occurred_at": "2024-01-01T00:00:00Z"}}'- If Tares has auth on, send the request with an
Authorization: Bearerheader holding an ingest-scoped API key. Without auth, no header is needed. - Open the source page. Under Recent events, confirm the event arrived with the fixed event type
pagerduty_incident. Under Fields, confirmevent.event_typeandevent.resource_typeshow up and fill theincident_eventandresource_typelabels. - Post the same payload with
incident.resolvedas the event type and check thatincident_eventchanges whileservicestaysnightly-backup-cron. - In PagerDuty, create a v3 webhook subscription whose delivery URL is the ingest URL. Add the Bearer header to the delivery method when Tares has auth on. Choose
incident.triggeredandincident.resolved, and pick the scope: account, team or service. Then trigger a test incident on the service that watches the cron job and confirm it lands the same way as your sample.
What you get
- You know the ingest URL, auth and label mapping work before a real cron job stops.
- Triggered and resolved incidents both show in Recent events under one stable
servicekey. - Fields shows which payload fields arrive and how often, so you can add more labels before the real incident.
- The whole PagerDuty payload is stored lossless, so nothing is lost if you add a label later.
- You can build triggers on the
incident_eventlabel, for example to act onincident.triggeredonly. You start from a mapping you have already seen work.
When something else fits
- If your cron job alerts come from Prometheus rules routed through Alertmanager, the Alertmanager connector fans each alert out into its own event and has its own test batch to post.
- If you want the full picture of how Tares handles alert sources, start from AI SRE.
Related
Last updated on