How do I test Datadog monitors about slow database queries before a real incident?
Tares lets you test a Datadog slow-query monitor before a real incident by posting a sample payload to the webhook source’s ingest URL. You then read Recent events and Fields on the source page to confirm the label mapping. Datadog reaches Tares through the webhook connector and a vendor setup, so you rehearse the whole path without waiting for a slow query.
How it works
Tares has no connector of its own for Datadog today. A Datadog webhook posts to a Tares webhook source, which stores the payload lossless and maps the fields you declare as labels.
- You write the payload in Datadog’s webhook Payload field as JSON, built from Datadog variables such as $ALERT_ID, $EVENT_MSG and $LINK. The shape is yours.
- Keep the payload flat. The event type field and the text template read top-level fields only.
- The source needs one primary label. Every other label maps a payload field you want to correlate on.
- A push source such as the webhook has no polling. The ingest URL is the only thing Datadog needs.
test_sourceon a push source takes no payload and only returns the ingest endpoint, so it does not check your label mapping. To check the mapping, post a sample payload yourself and read the source page.
This is the same check you would run for any push source, for example an Alertmanager receiver, which you verify the same way with a test POST.
Set it up
- Create a webhook source in Sources, Add source, webhook, or ask a connected agent to create one and return the ingest URL. Declare a label for each field your Datadog payload carries and mark one as primary. The field names below are examples, use the ones in 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 }Rename the source and point the labels at your slow-query fields. For example, make the primary label a database or service name from your payload.
-
Copy the ingest endpoint from the source page.
-
Post a sample payload shaped like the one your Datadog webhook will send. Use a flat JSON object with the same top-level fields.
curl -X POST http://localhost:8787/ingest/<ingest_key> \
-H 'Content-Type: application/json' \
-d '{"action": "deploy", "sender": "ci", "pipeline": "web"}'Swap the body for your slow-query fields before you run it. If Tares has auth on, send an ingest-scoped API key as an Authorization: Bearer header.
-
Open the source page and check Recent events. Your sample should appear as an event. Open Fields to see which payload fields arrive and how often, then confirm the primary label holds the value you want to key on. Fix the label mapping and post again until it is right.
-
Set up 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 the webhook in the slow-query monitor message with
@webhook-followed directly by the webhook’s name, with a hyphen and no space. If you named the webhook slow-queries, write@webhook-slow-queries. The monitor then calls it. -
Trigger the monitor in a safe way, such as a test notification or a temporary low threshold. Check Recent events again to see the real Datadog delivery arrive with the same labels as your sample.
What you get
- Confidence that the label mapping works before an incident, because you have read your own sample on Recent events and Fields.
- A primary label that matches the entity you care about, such as a database or service, so slow-query events correlate with your other sources in Tares.
- A checked Datadog path from monitor message to webhook to Tares event, including the Bearer header when auth is on.
- A repeatable check. Post a sample payload any time you change the payload or labels.
For how this fits into a wider setup, see AI SRE.
When something else fits
- If your slow-query signal is a Prometheus rule, route it through Alertmanager and use the alertmanager connector, which makes one event per alert.
- If you want to rehearse without involving Datadog at all, the sample POST in step 3 is enough. Datadog’s own webhook settings only matter once you want a real delivery.