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.
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.
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.
| Check | Original agent | Fixed agent |
|---|---|---|
| Muted only the staging monitor | 0 of 3 | 3 of 3 |
Scripted agent, no model. Recorded with CLI 0.4.74.
The one-line fix
- 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 beforeConnect your agent to the Datadog mock
When ancha runs your agent, it sets:
DATADOG_API_URLDD_API_KEYDD_APP_KEYDATADOG_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
/api/v1/dashboard/api/v1/dashboard/:iddowntime
/api/v1/downtime/api/v1/downtime/api/v1/downtime/:id/api/v1/downtime/:id/api/v1/downtime/:id/api/v2/downtime/api/v2/downtime/api/v2/downtime/:id/api/v2/downtime/:id/api/v2/downtime/:idevents
/api/v1/events/api/v1/eventsincidents
/api/v2/incidents/api/v2/incidents/api/v2/incidents/:id/api/v2/incidents/:idlogs
/api/v2/logs/events/searchmonitor
/api/v1/monitor/api/v1/monitor/:id/api/v1/monitor/:id/mute/api/v1/monitor/:id/unmute/api/v1/monitor/:monitor_id/downtimes/api/v1/monitor/search/api/v2/monitor/:monitor_id/downtime_matchesquery
/api/v1/queryTested together
All 43 toolsDatadog 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.
Ancha is not affiliated with Datadog.