Skip to Content

How do I test Datadog monitors about error spikes before a real incident?

Tares lets you test a Datadog error spike monitor before a real incident by posting a sample payload to the source’s ingest URL and reading the result on the source page. Datadog reaches Tares through the webhook connector and a Datadog-side webhook setup. Tares has no connector of its own for Datadog today. Check the label mapping in Fields and the event in Recent events, then point the monitor at the same URL.

How it works

A Datadog webhook posts a JSON body that you write yourself in the webhook Payload field, using Datadog variables such as $ALERT_ID, $EVENT_MSG and $LINK. Tares receives that body on a webhook source and stores it lossless. Labels you declare map payload fields into the event, and one label is marked primary.

Because the payload is yours, the test is the same as the real thing: any JSON you post to the ingest URL goes through the same label mapping as a delivery from Datadog.

  • Keep the payload flat. event_type_field and text_template read top-level fields only.
  • On a push source, test_source takes no payload and only returns the ingest endpoint. Use it to get the URL, not to check labels.
  • To check the mapping, post a sample payload to the ingest URL and read Recent events and Fields on the source page. Fields shows which payload fields arrive and how often.
  • On a secured instance (tares up --auth), the sender needs an Authorization: Bearer header holding an ingest-scoped API key. That header is the credential for Datadog too. Without auth on, no key is needed.

For the wider picture of how events from different sources work together, see AI SRE.

Set it up

  1. Create the source. Ask a connected agent: “Use tares to create a webhook source for my Datadog error spike monitor.” The agent calls create_source and returns the ingest URL. Or use Sources → Add source → webhook in the console and copy the ingest endpoint from the source page.

  2. Declare labels for the fields your Datadog payload will carry, and mark one as primary. The webhook source looks like this. Replace the field names with the top-level fields of your own payload:

- name: ci-events connector: webhook config: event_type_field: action text_template: '{action} by {sender}' labels: - { name: pipeline, field: pipeline, primary: true }
  1. Post a sample payload to the ingest URL. Use a flat JSON object shaped like the payload you plan to write in Datadog:
curl -X POST http://localhost:8787/ingest/<ingest_key> \ -H 'Content-Type: application/json' \ -d '{"action": "deploy", "sender": "ci", "pipeline": "web"}'

If your instance has auth on, add the Bearer Authorization header with an ingest-scoped API key to the request.

  1. Open the source page. Under Recent events, confirm the event arrived with the event type and text you expect. Under Fields, confirm each payload field you mapped shows up, and that your primary label is a reliable key. Adjust the labels and post again until it looks right.

  2. Connect Datadog:

    • In Datadog, open the Webhooks integration and add a webhook whose URL is the Tares ingest URL.
    • Write the payload as flat 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 error spike monitor message, so the monitor calls it.
  3. Trigger the monitor in a safe way, for example against a test scope, and check Recent events again. The event from Datadog should carry the same labels as your sample.

What you get

  • Confidence that the mapping works before an incident: the labels, the primary key and the event text are already checked against a sample.
  • A visible record in Recent events and Fields, so you can see exactly what Datadog sends and which fields are reliable.
  • A source that is ready for the real alert. When the monitor fires on an error spike, the delivery lands on the same URL and goes through the mapping you already tested.
  • A clear separation between the two checks. The sample post proves the mapping in Tares, and the monitor call proves the Datadog side: the URL, the payload and the header.

When something else fits

  • If your error spike alerts come from Prometheus rules routed through Alertmanager, the alertmanager connector fits better. It makes one event per alert and tracks firing and resolved.
  • If you want to check a label mapping, post a sample payload to the ingest URL. Do not rely on test_source for that, because it only returns the ingest endpoint on a push source.

Still stuck? Get help

Last updated on