Skip to Content

How do I test Datadog monitors about crash loops before a real incident?

Tares lets you test a Datadog crash loop monitor by posting a sample JSON payload to the webhook source’s ingest URL. You then read Recent events and Fields on the source page to check that the labels map the way you want. Datadog reaches Tares through the webhook connector and a vendor setup, so you can finish this check before the monitor ever fires.

How it works

Tares has no connector of its own for Datadog today. A Datadog webhook posts JSON to a Tares webhook source, and the source stores the payload lossless. You declare labels to map payload fields into the envelope, and you mark one label primary.

The payload shape is yours. In Datadog you write the webhook Payload field as a JSON object from Datadog variables such as $ALERT_ID, $EVENT_MSG and $LINK. Tares reads what you send, so the test is to post a body of the shape you configured and see what Tares makes of it.

Two views on the source page answer the testing question:

  • Recent events shows the events that arrived.
  • Fields shows which payload fields arrive and how often, so you can pick a reliable key.

For a push source, test_source takes no payload. It only returns the ingest endpoint, so it does not check your label mapping. Post a sample payload to the ingest URL instead.

Keep the payload flat. event_type_field and text_template read top-level fields only.

If you want to read more about the connector itself, see the webhook connector page. For the wider picture of how Tares fits into incident response, see AI SRE.

Set it up

  1. Create the webhook source. In the console choose Sources → Add source → webhook. Or ask a connected agent: “Use tares to create a webhook source for my Datadog monitor alerts.” The agent calls create_source and returns the ingest URL.
  2. Declare a label for each payload field you want to correlate on, and mark one primary. This is the webhook page’s example. The field names in it are only examples, so replace them with the fields your Datadog payload carries.
- name: ci-events connector: webhook config: event_type_field: action text_template: '{action} by {sender}' labels: - { name: pipeline, field: pipeline, primary: true }
  1. Copy the ingest endpoint from the source page. It ends in /ingest/ followed by the source’s ingest key.
  2. Post a sample body to it. The body below is the webhook page’s example. Swap it for a flat JSON object with the fields you plan to put in the Datadog Payload field.
curl -X POST http://localhost:8787/ingest/<ingest_key> \ -H 'Content-Type: application/json' \ -d '{"action": "deploy", "sender": "ci", "pipeline": "web"}'
  1. If your Tares has auth on (tares up --auth), the request needs an Authorization: Bearer header holding an ingest-scoped API key. Creating a push source in the console mints one for it and shows it once.
  2. Open the source page. Check Recent events for your test event, and check Fields to see that each field you mapped arrives. If a label is missing or the primary label is wrong, edit the source, post again and re-check.
  3. Wire up Datadog once the mapping looks right:
    • In Datadog, open the Webhooks integration and add a webhook whose URL is the Tares ingest URL.
    • Write the payload as JSON from Datadog variables. When Tares has auth on, add custom headers as JSON with an Authorization Bearer header holding an ingest-scoped API key.
    • Put @webhook- followed by your webhook name in the crash loop monitor’s message, so the monitor calls it.
  4. Trigger a notification from the monitor in Datadog and read Recent events and Fields again. The shape you configured in Datadog is now the one you check, because you wrote it yourself.

What you get

  • A label mapping you have checked against a test event, with one primary label chosen before any real incident.
  • A view of which payload fields arrive and how often, so you can pick a reliable key for the crash loop monitor.
  • A working path from the monitor to Tares, covering the URL, the payload and, on a secured instance, the Bearer header.
  • The full payload kept lossless on each event, so a field you did not map is still stored with the event.

The same webhook source works for any Datadog monitor you point at it. Crash loops are the case you test first.

When something else fits

  • If your crash loop alerts come from Prometheus rules routed through Alertmanager, use the Alertmanager connector. It turns each alert in a batch into its own event and carries grouping and resolved status.
  • If you only need to confirm that a source has an ingest endpoint, test_source returns it. It does not check labels, so use a posted sample for that.

Still stuck? Get help

Last updated on