InTouch Hub · Blue Isle Software

Datadog

Query Datadog monitors and timeseries metrics and post events via the Datadog v1 REST API.

datadogmonitoringmetricsdevops

Datadog

Query Datadog monitors and timeseries metrics, and post events to the Datadog event stream, using the Datadog v1 REST API (https://docs.datadoghq.com/api/latest/).

Standard-library Python only (urllib, json) — no external dependencies. Response bodies are returned as a JSON string in result along with the HTTP status; bodies are capped at ~5 MB.

Operations

operation method & endpoint required inputs keys needed
list_monitors GET /api/v1/monitor apiKey + appKey
get_monitor GET /api/v1/monitor/{monitorId} monitorId apiKey + appKey
query_metrics GET /api/v1/query?from=&to=&query= query, from, to apiKey + appKey
post_event POST /api/v1/events title, text apiKey only

from / to are UNIX epoch seconds. Optional post_event inputs: tags (comma-separated), alertType (error/warning/info/success), priority (normal/low).

Authentication

Datadog authenticates with two headers:

Create them in Datadog under Organization Settings:

  1. API KeysNew Key → copy into the apiKey input.
  2. Application KeysNew Key → copy into the appKey input.

post_event needs only apiKey. list_monitors, get_monitor and query_metrics need both apiKey and appKey.

Region / site

Default site is datadoghq.com (US1). Override the site input for other regions — e.g. datadoghq.eu, us3.datadoghq.com, us5.datadoghq.com, ap1.datadoghq.com, ddog-gov.com. Requests go to https://api.<site>.

Examples

List all monitors:

operation = list_monitors
apiKey    = <your-api-key>
appKey    = <your-app-key>

Query the last hour of host CPU idle (epoch seconds for from/to):

operation = query_metrics
apiKey    = <your-api-key>
appKey    = <your-app-key>
query     = avg:system.cpu.idle{*}
from      = 1718200000
to        = 1718203600

Post a deployment event:

operation = post_event
apiKey    = <your-api-key>
title     = Deploy: api v8.0.0
text      = Rolled out api v8.0.0 to prod
tags      = env:prod,team:sre
alertType = info