Test an on-call agent with a Datadog API mock.

A local Datadog API for your on-call agent’s tests. Downtimes it schedules stay in place, so a test can check which alerts it silenced and for how long.

See the example
Monitors

Orders API p95 latency

  • env:prodOK

    Not muted

  • env:stagingOK

    Muted for 30 minutes

Downtime on the staging monitor

Staging deploy of the orders API.

The monitors after the fixed agent runs. Starting data and checks from scene.yaml.

An agent muted every monitor

The orders API was deploying to staging for 30 minutes. The agent should have muted the staging latency monitor and left production alerting. It found the right monitor, then sent the downtime without its monitor_id, and a downtime without one covers every monitor.

The test checks the downtimes after the run: one, on the staging monitor, for 30 minutes at most, and nothing global. Changing one line in the agent makes it pass, with the test unchanged.

Downtime check3 trials / version
CheckOriginal agentFixed agent
Muted only the staging monitor0 of 33 of 3

Scripted agent, no model. Recorded with CLI 0.4.74.

The one-line fix

agent.mjs
- const target = { scope: ['*'] };+ const target = { scope: ['*'], monitor_id: staging.id };

Run it yourself

Save agent.mjs and scene.yaml in an empty directory. You need Node.js 24.

npm install -g @ancha-labs/cli
ancha init --agent "node agent.mjs"
ancha run scene.yaml --local -n 3
ancha baseline save before
# change { scope: ['*'] } to { scope: ['*'], monitor_id: staging.id } in agent.mjs
ancha run scene.yaml --local -n 3 --compare before

Connect your agent to the Datadog mock

When ancha runs your agent, it sets:

  • DATADOG_API_URL
  • DD_API_KEY
  • DD_APP_KEY
  • DATADOG_WEBHOOK_TOKEN

Point the client you already use at them.

import { client, v1 } from '@datadog/datadog-api-client';

// The client reads DD_API_KEY and DD_APP_KEY from the environment.
const configuration = client.createConfiguration({
  baseServer: new client.BaseServerConfiguration(process.env.DATADOG_API_URL, {}),
  enableRetry: false,
});
const monitors = new v1.MonitorsApi(configuration);

Locally, ancha runs your agent as an ordinary process, so keep real Datadog credentials out of its environment.

See all 27 endpoints

dashboard

GET/api/v1/dashboard
GET/api/v1/dashboard/:id

downtime

GET/api/v1/downtime
POST/api/v1/downtime
GET/api/v1/downtime/:id
PUT/api/v1/downtime/:id
DELETE/api/v1/downtime/:id
GET/api/v2/downtime
POST/api/v2/downtime
GET/api/v2/downtime/:id
PATCH/api/v2/downtime/:id
DELETE/api/v2/downtime/:id

events

GET/api/v1/events
POST/api/v1/events

incidents

GET/api/v2/incidents
POST/api/v2/incidents
GET/api/v2/incidents/:id
PATCH/api/v2/incidents/:id

logs

POST/api/v2/logs/events/search

monitor

GET/api/v1/monitor
GET/api/v1/monitor/:id
POST/api/v1/monitor/:id/mute
POST/api/v1/monitor/:id/unmute
GET/api/v1/monitor/:monitor_id/downtimes
GET/api/v1/monitor/search
GET/api/v2/monitor/:monitor_id/downtime_matches

query

GET/api/v1/query

Tested together

All 43 tools

Datadog API mock FAQ

How do I test an AI SRE agent against Datadog?

Seed the monitors, metric series and logs the incident needs, point the agent at Ancha’s Datadog endpoint with the supplied keys, and check the end state: monitor states and the downtimes the agent created.

Does time move during a test?

Yes. The world’s clock is simulated, so a 30-minute downtime or a two-hour wait takes seconds. Schedule against the server’s Date header, as the example agent does; the machine’s clock keeps real time.

Does a monitor change state when its metric changes?

In a living world, monitors evaluate their query against the world’s metric series, so a fix can bring an alert back to OK. A static world, like the example, keeps the seeded states.

Will this touch my Datadog account?

No. Ancha simulates the Datadog API, and your agent talks to it through the DATADOG_API_URL and keys that ancha sets.

How is this different from a Datadog trial account?

A trial account is a real Datadog account: it keeps what earlier runs left in it, and your agent needs real API and application keys. The mock starts from your test’s data on every run, and your agent connects with the variables ancha sets.

Run the example on your machine.

Book a demo

Ancha is not affiliated with Datadog.