Skip to content
← Community packages

Inspect Datadog monitors, incidents, logs, and dashboards with dry-run mutations.

Browse files

  • Other
  • datadog
  • monitors
  • incidents
  • logs
  • dashboards
  • observability
  • alerts
  • dry-run
License
MIT
Published
August 22, 2026
Pinned commit
24a475b
Rating
No ratings yet
Forks
0
Stars
0
Adaptation effort

README

@kody/datadog

Intent

Official Datadog helpers so Kody agents can inspect the caller's monitors, incidents, logs, and dashboards — not a shared org. Auth is a saved API key plus application key, not OAuth. Reads are free-form. Creates, updates, deletes, mute, and unmute support dryRun: true and require confirm: true before they contact Datadog.

This listing is meant to be forked. After you fork, save your own datadogApiKey and datadogApplicationKey and call the helpers in your account. No organization names, monitor IDs, or dashboard IDs are baked in.

Agent setup

  1. In Datadog, open Organization Settings → API Keys and Application Keys. Create one of each. Scope the application key to the minimum permissions you need (monitors, incidents, logs, dashboards).
  2. Save both secrets in Kody (do not paste the values in chat):

https://kody.codes/account/secrets/new?name=datadogApiKey&description=Datadog%20API%20key%20for%20the%20HTTP%20API&allowedHosts=api.datadoghq.com,api.us3.datadoghq.com,api.us5.datadoghq.com,api.datadoghq.eu,api.ap1.datadoghq.com,api.ap2.datadoghq.com,api.uk1.datadoghq.com,api.ddog-gov.com,api.us2.ddog-gov.com&scope=user

https://kody.codes/account/secrets/new?name=datadogApplicationKey&description=Datadog%20application%20key%20for%20read%20and%20management%20API%20calls&allowedHosts=api.datadoghq.com,api.us3.datadoghq.com,api.us5.datadoghq.com,api.datadoghq.eu,api.ap1.datadoghq.com,api.ap2.datadoghq.com,api.uk1.datadoghq.com,api.ddog-gov.com,api.us2.ddog-gov.com&scope=user

  1. In the account secrets UI, approve the Datadog API hosts you use (at least api.datadoghq.com for US1).
  2. Share this listing as https://kody.codes/@kody/datadog

Auth

API key + application key (secret-backed). There is no Datadog OAuth integration in this package. Do not open /connect/oauth for Datadog.

SecretPurpose
datadogApiKeyOrganization API key (DD-API-KEY)
datadogApplicationKeyApplication key (DD-APPLICATION-KEY)

Every request sends both headers. Submission-only endpoints that accept only an API key are out of scope here.

Hosts and sites

Pass site when the account is not US1. Aliases: us1, us3, us5, eu, ap1, ap2, uk1, gov.

SiteAPI host
us1 (default)api.datadoghq.com
us3api.us3.datadoghq.com
us5api.us5.datadoghq.com
euapi.datadoghq.eu
ap1api.ap1.datadoghq.com
ap2api.ap2.datadoghq.com
uk1api.uk1.datadoghq.com
govapi.ddog-gov.com

Multi-account

Pass account: "work" to use secrets datadogApiKey-work and datadogApplicationKey-work. Or pass apiKeySecretName / applicationKeySecretName. There are no hard-coded account aliases.

https://kody.codes/account/secrets/new?name=datadogApiKey-work&description=Datadog%20API%20key%20for%20the%20work%20account&allowedHosts=api.datadoghq.com,api.us3.datadoghq.com,api.us5.datadoghq.com,api.datadoghq.eu,api.ap1.datadoghq.com,api.ap2.datadoghq.com,api.uk1.datadoghq.com,api.ddog-gov.com,api.us2.ddog-gov.com&scope=user

https://kody.codes/account/secrets/new?name=datadogApplicationKey-work&description=Datadog%20application%20key%20for%20the%20work%20account&allowedHosts=api.datadoghq.com,api.us3.datadoghq.com,api.us5.datadoghq.com,api.datadoghq.eu,api.ap1.datadoghq.com,api.ap2.datadoghq.com,api.uk1.datadoghq.com,api.ddog-gov.com,api.us2.ddog-gov.com&scope=user

Exports

  • kody:@kody/datadog — action dispatcher (defaults to smoke-test); also re-exports every helper below
  • kody:@kody/datadog/validate — validate the API key and read the current user
  • kody:@kody/datadog/monitors — list/search/get; create/update/delete/mute/unmute with dryRun
  • kody:@kody/datadog/incidents — list/search/get; create/update/delete with dryRun
  • kody:@kody/datadog/logs — search logs (POST /api/v2/logs/events/search)
  • kody:@kody/datadog/dashboards — list/get; create/update/delete with dryRun
  • kody:@kody/datadog/smoke-test — dry-run self-check, then a live read when both secrets exist
  • kody:@kody/datadog/scheduled-status — no-argument monitor-state wrapper used by the disabled job

Mutation safety

  • Pass dryRun: true on any write to return { dryRun: true, method, path, host } without contacting Datadog.
  • Live writes also throw unless confirm: true.
  • Do not create, mute, or delete anyone's monitors, incidents, or dashboards from a smoke test or scheduled job.
import { createMonitor, deleteMonitor } from 'kody:@kody/datadog/monitors'

const preview = await createMonitor({
	type: 'query alert',
	query: 'avg(last_5m):avg:system.cpu.user{*} > 95',
	name: 'High CPU',
	dryRun: true,
})

const deleted = await deleteMonitor({
	monitorId: 12345,
	confirm: true,
})

Jobs

The monitor-status job is declared disabled. It is a no-argument wrapper around scheduled-status (read-only monitor state counts). Enable it only after you confirm the keys, hosts, and site you want it to use.

Smoke test

import datadog from 'kody:@kody/datadog'

export default async function main() {
	return await datadog()
}

Without both secrets this still returns { ok: true, live: false } plus the setup URLs. With the secrets saved it validates the keys and lists a sample of monitors and dashboards — no writes.

Example

import datadog from 'kody:@kody/datadog'

export default async function main() {
	return await datadog({
		action: 'search-logs',
		query: 'status:error',
		from: 'now-15m',
		to: 'now',
	})
}

Branding

community-icon.svg is Datadog's official Bits mark (Simple Icons datadog, sourced from Datadog brand assets) on Datadog purple #632CA6. Datadog® is a trademark of Datadog, Inc. This package is not affiliated with or endorsed by Datadog.

Docs

Report this listing

Log in to report this listing.