Skip to content

Datadog

Metrics, logs, spans, monitors, SLOs and incidents from Datadog

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/datadog/index.md to help me query Datadog with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Group your metrics by namespace

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT split_part(metric, '.', 1) AS namespace, count(*) AS metrics
FROM datadog.main.metrics
GROUP BY namespace
ORDER BY metrics DESC

Quick start

Choose where to run Datadog, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'datadog' AS datadog (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-datadog-worker'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

datadog credentials

Connection to one Datadog organization: an API key, an application key with read scopes, and the site the organization lives on (datadoghq.com by default).

Get these credentials →
secret.sql
CREATE SECRET datadog (
    TYPE datadog,
    api_key   '<DATADOG_API_KEY>',  -- required, secret
    app_key   '<APP_KEY>',  -- required, secret
    site      '<site>',
    base_url  '<base_url>',
    timeout   '<timeout>',
    page_size '<page_size>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT split_part(metric, '.', 1) AS namespace, count(*) AS metrics
FROM datadog.main.metrics
GROUP BY namespace
ORDER BY metrics DESC
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'datadog' AS datadog (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-datadog-worker'
);

Overview

Datadog as SQL: query metrics, search logs, spans, events and the audit trail, and list monitors, SLOs, incidents, dashboards, synthetic tests, hosts and users, on any Datadog site. Read-only.

Catalog

Everything datadog exposes once attached — read straight from the worker's released build.

datadog 2 schemas
main 1 table · 11 functions

Datadog telemetry: metric queries as long rows, logs, APM spans, events and the audit trail.

Schema examples (12)
Examples (12)

Metric names by namespace

SELECT split_part(metric, '.', 1) AS namespace, count(*) AS metrics
FROM datadog.main.metrics
GROUP BY namespace
ORDER BY metrics DESC;

Average CPU per production host over one hour

SELECT tags['host'] AS host, avg(value) AS avg_cpu
FROM datadog.main.metrics_query('avg:system.cpu.user{env:prod} by {host}', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
GROUP BY host
ORDER BY avg_cpu DESC;

Type and unit of one metric

SELECT type, unit, per_unit
FROM datadog.main.metric_metadata('system.net.bytes_rcvd');

Tag cardinality per key for one metric

SELECT key, count(*) AS distinct_values
FROM datadog.main.metric_tags('system.cpu.user')
GROUP BY key
ORDER BY distinct_values DESC;
8 more examples

Production error logs per service for one day (status and env run in Datadog)

SELECT service, count(*) AS errors
FROM datadog.main.logs('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00')
WHERE status = 'error' AND env = 'prod'
GROUP BY service
ORDER BY errors DESC;

Log volume per service and status for one day, counted in Datadog

SELECT groups['service'] AS service, groups['status'] AS status,
  value AS logs
FROM datadog.main.logs_aggregate('env:prod', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00', group_by := 'service,status')
ORDER BY logs DESC;

p95 latency and error rate per endpoint of one service

SELECT resource_name, count(*) AS spans,
  quantile_cont(duration_seconds, 0.95) AS p95_s,
  avg(is_error::INT) AS error_rate
FROM datadog.main.spans('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
WHERE service = 'web' AND env = 'prod'
GROUP BY resource_name
ORDER BY p95_s DESC;

p99 latency per endpoint, computed in Datadog (span durations are in nanoseconds)

SELECT groups['resource_name'] AS endpoint, value / 1e6 AS p99_ms
FROM datadog.main.spans_aggregate('service:web env:prod', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00', group_by := 'resource_name', aggregation := 'pc99', metric := '@duration')
ORDER BY p99_ms DESC;

GitHub deploy events per day for one month

SELECT date_trunc('day', ts) AS day, count(*) AS deploys
FROM datadog.main.events('tags:deploy', TIMESTAMPTZ '2026-10-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 00:00:00+00')
WHERE source = 'github'
GROUP BY day
ORDER BY day;

Who changed what during one week

SELECT user_email, asset_type, count(*) AS changes
FROM datadog.main.audit_events('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-08 00:00:00+00')
WHERE action = 'modified'
GROUP BY ALL
ORDER BY changes DESC;

A service filter whose value contains quotes

SELECT datadog.main.search_term('service', 'checkout "v2"') AS term;

Read one key from a tag list

SELECT datadog.main.tag_map(['env:prod', 'team:core', 'legacy'])['team'] AS team;
Tables
metrics 2 examples7 cols

Every metric name in the organization, with its Metrics without Limits tag configuration if any.

Columns
metricnot null VARCHAR
Metric name, e.g. 'system.cpu.user'.
has_tag_configurationnot null BOOLEAN
True when the metric has a Metrics without Limits tag configuration.
metric_type VARCHAR
Type from the tag configuration: gauge, count, rate or distribution.
configured_tags VARCHAR[]
Tag keys kept by the tag configuration.
include_percentiles BOOLEAN
Distribution metrics: whether percentiles are enabled.
created_at TIMESTAMP WITH TIME ZONE
When the tag configuration was created.
modified_at TIMESTAMP WITH TIME ZONE
When the tag configuration was last changed.
ConstraintsPRIMARY KEY (metric)
Examples (2)

Metric names by namespace

SELECT split_part(metric, '.', 1) AS namespace, count(*) AS metrics
FROM datadog.main.metrics
GROUP BY namespace
ORDER BY metrics DESC;

Distribution metrics with percentiles

SELECT metric, configured_tags
FROM datadog.main.metrics
WHERE metric_type = 'distribution' AND include_percentiles
ORDER BY metric;
Link
Scalar functions
search_term (attribute VARCHAR, value VARCHAR) 3 examples

Build a Datadog search term attribute:"value" with the value quoted and escaped

Arguments
attribute VARCHAR
Attribute, tag key or @facet to match, e.g. 'service'.
value VARCHAR
The exact value to match; quoted and escaped.
ReturnsVARCHAR
Examples (3)

A service filter whose value contains quotes

SELECT datadog.main.search_term('service', 'checkout "v2"') AS term;

An OR query over a list of hosts, ready to paste into logs()

SELECT string_agg(datadog.main.search_term('host', h), ' OR ' ORDER BY h) AS hosts_query
FROM (VALUES ('web-1'), ('web-2')) t(h);
SELECT string_agg(datadog.main.search_term('host', h), ' OR ' ORDER BY h) AS q
FROM (VALUES ('web-1'), ('web-2')) t(h);
Link
tag_map (tags VARCHAR[]) 2 examples

Turn a list of Datadog key:value tags into a MAP(VARCHAR, VARCHAR) keyed by tag key

Arguments
tags VARCHAR[]
Datadog tags, each a key:value string (a bare tag without a colon is allowed).
ReturnsMAP(VARCHAR, VARCHAR)
Examples (2)

Read one key from a tag list

SELECT datadog.main.tag_map(['env:prod', 'team:core', 'legacy'])['team'] AS team;
SELECT m['env'] AS env, m['team'] AS team, m['legacy'] AS legacy
FROM (SELECT datadog.main.tag_map(['env:prod', 'team:core', 'team:web', 'legacy']) AS m);
Link
Table functions
audit_events (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE, max_rows := BIGINT, newest_first := BOOLEAN) 1 example

Search the Datadog audit trail in a time window; filters on action/user/asset run in Datadog

Positional arguments
query VARCHAR
Datadog search query, e.g. 'service:web status:error'; '*' matches everything.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Named arguments
max_rows := BIGINT
Stop after this many rows; NULL reads the whole window. · default null
newest_first := BOOLEAN
Page from the newest record backwards (with max_rows: the latest N). · default false
Returns columns
id VARCHAR
Audit event id.
ts TIMESTAMPTZ
When the action happened.
service VARCHAR
Product area, e.g. 'monitor', 'dashboard', 'apikey'.
event_name VARCHAR
Event name (@evt.name), e.g. 'Request', 'Authentication'.
action VARCHAR
Action (@action): created, modified, deleted, accessed ...
asset_type VARCHAR
Type of the asset acted on (@asset.type).
asset_id VARCHAR
Id of the asset acted on (@asset.id).
asset_name VARCHAR
Name of the asset acted on (@asset.name).
user_email VARCHAR
Email of the acting user (@usr.email).
message VARCHAR
Audit message.
tags MAP(VARCHAR, VARCHAR)
Event tags as a MAP.
attributes JSON
The full audit attributes, JSON.
Example

Who changed what during one week

SELECT user_email, asset_type, count(*) AS changes
FROM datadog.main.audit_events('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-08 00:00:00+00')
WHERE action = 'modified'
GROUP BY ALL
ORDER BY changes DESC;
Link
events (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE, max_rows := BIGINT, newest_first := BOOLEAN) 1 example

Search the Datadog event stream in a time window; filters on source/status/host/service run in Datadog

Positional arguments
query VARCHAR
Datadog search query, e.g. 'service:web status:error'; '*' matches everything.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Named arguments
max_rows := BIGINT
Stop after this many rows; NULL reads the whole window. · default null
newest_first := BOOLEAN
Page from the newest record backwards (with max_rows: the latest N). · default false
Returns columns
id VARCHAR
Event id.
ts TIMESTAMPTZ
Event time.
title VARCHAR
Event title.
message VARCHAR
Event text.
source VARCHAR
Source: the integration or 'my_apps', e.g. 'github', 'kubernetes'.
status VARCHAR
Alert status: error, warning, info, success, user_update, recommendation, snapshot.
priority VARCHAR
Priority: normal or low.
host VARCHAR
Host the event is about.
service VARCHAR
Service the event is about.
aggregation_key VARCHAR
Key that groups related events.
tags MAP(VARCHAR, VARCHAR)
Event tags as a MAP.
attributes JSON
The full event attributes, JSON.
Example

GitHub deploy events per day for one month

SELECT date_trunc('day', ts) AS day, count(*) AS deploys
FROM datadog.main.events('tags:deploy', TIMESTAMPTZ '2026-10-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 00:00:00+00')
WHERE source = 'github'
GROUP BY day
ORDER BY day;
Link
logs (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE, indexes := VARCHAR, max_rows := BIGINT, newest_first := BOOLEAN, storage_tier := VARCHAR) 2 examples

Search Datadog logs in a time window; SQL filters on service/status/host/env/source run in Datadog

Positional arguments
query VARCHAR
Datadog search query, e.g. 'service:web status:error'; '*' matches everything.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Named arguments
indexes := VARCHAR
Comma-separated log index names to search; NULL searches every index ('*'). · default null
max_rows := BIGINT
Stop after this many rows; NULL reads the whole window. · default null
newest_first := BOOLEAN
Page from the newest record backwards (with max_rows: the latest N). · default false
storage_tier := VARCHAR
Storage tier: 'indexes' (default), 'online-archives' or 'flex'. · default "indexes"
Returns columns
id VARCHAR
Log event id (unique, opaque).
ts TIMESTAMPTZ
Log timestamp.
status VARCHAR
Log status (level): emergency .. debug, e.g. 'error', 'warn', 'info'.
service VARCHAR
Service that emitted the log.
host VARCHAR
Host that emitted the log.
env VARCHAR
The env tag (env:prod -> 'prod'), hoisted from tags.
source VARCHAR
The source tag (integration / language), hoisted from tags.
message VARCHAR
Log message.
trace_id VARCHAR
Correlated APM trace id (dd.trace_id attribute), if any.
tags MAP(VARCHAR, VARCHAR)
Every tag on the log as a MAP (env -> 'prod'); repeated keys join values with ','.
attributes JSON
The log's custom attributes (facets referenced as @path in queries), JSON.
Examples (2)

Production error logs per service for one day (status and env run in Datadog)

SELECT service, count(*) AS errors
FROM datadog.main.logs('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00')
WHERE status = 'error' AND env = 'prod'
GROUP BY service
ORDER BY errors DESC;

The 50 latest 5xx logs of one service, with a facet read from attributes

SELECT ts, host, message, attributes->>'$.http.status_code' AS http_status
FROM datadog.main.logs('service:web @http.status_code:>=500', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00', max_rows := 50, newest_first := true)
ORDER BY ts DESC;
Link
logs_aggregate (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE, aggregation := VARCHAR, group_by := VARCHAR, group_limit := BIGINT, metric := VARCHAR, rollup := VARCHAR) 2 examples

Aggregate Datadog logs (count, percentiles ...) by facets, as totals or a timeseries

Positional arguments
query VARCHAR
Datadog search query selecting the records, e.g. 'service:web'; '*' for all.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Named arguments
aggregation := VARCHAR
count (default), cardinality, sum, min, max, avg, median or pc75..pc99. · default "count"
group_by := VARCHAR
Comma-separated facets to group by, e.g. 'service,status' or '@http.status_code'. · default null
group_limit := BIGINT
Top groups kept per group_by facet, ranked by the aggregate (1 to 10000). · default 10
metric := VARCHAR
Measure to aggregate, e.g. '@duration'; required for every aggregation except count. · default null
rollup := VARCHAR
Bucket width such as '5m' or '1h' for a timeseries (one row per bucket); NULL returns one total per group. · default null
Returns columns
groups MAP(VARCHAR, VARCHAR)
The group-by facet values of the row as a MAP (service -> 'web'); empty without group_by.
ts TIMESTAMPTZ
Bucket start for a timeseries (rollup set); NULL for a total.
value DOUBLE
The aggregate value.
aggregation VARCHAR
The aggregation that produced value, e.g. 'count' or 'pc95'.
metric VARCHAR
The aggregated measure, e.g. '@duration'; NULL for count.
Examples (2)

Log volume per service and status for one day, counted in Datadog

SELECT groups['service'] AS service, groups['status'] AS status,
  value AS logs
FROM datadog.main.logs_aggregate('env:prod', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00', group_by := 'service,status')
ORDER BY logs DESC;

Hourly p95 of a log measure

SELECT ts, value AS p95_ms
FROM datadog.main.logs_aggregate('service:web', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 06:00:00+00', aggregation := 'pc95', metric := '@duration', rollup := '1h')
ORDER BY ts;
Link
metric_metadata (metric VARCHAR) 1 example

Type, unit, description and integration of one Datadog metric

Arguments
metric VARCHAR
Metric name, e.g. 'system.cpu.user'.
Returns columns
metric VARCHAR
Metric name.
type VARCHAR
Metric type: gauge, count, rate or distribution.
description VARCHAR
Description set on the metric.
short_name VARCHAR
Short display name.
unit VARCHAR
Unit, e.g. 'byte'.
per_unit VARCHAR
Per-unit, e.g. 'second' for bytes per second.
statsd_interval BIGINT
Flush interval in seconds for DogStatsD metrics.
integration VARCHAR
Integration that reports the metric, e.g. 'system'.
Example

Type and unit of one metric

SELECT type, unit, per_unit
FROM datadog.main.metric_metadata('system.net.bytes_rcvd');
Link
metric_tags (metric VARCHAR) 1 example

Every tag value reported for one Datadog metric, split into key and value

Arguments
metric VARCHAR
Metric name, e.g. 'system.cpu.user'.
Returns columns
metric VARCHAR
Metric name.
tag VARCHAR
The tag as Datadog stores it, 'key:value'.
key VARCHAR
Tag key (text before the first colon).
value VARCHAR
Tag value (text after the first colon; '' for a bare tag).
Example

Tag cardinality per key for one metric

SELECT key, count(*) AS distinct_values
FROM datadog.main.metric_tags('system.cpu.user')
GROUP BY key
ORDER BY distinct_values DESC;
Link
metrics_query (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE) 2 examples

Query Datadog metrics over a time window and return one row per series point

Arguments
query VARCHAR
A Datadog metric query, e.g. 'avg:system.cpu.user{env:prod} by {host}'. Comma-separate several.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Returns columns
metric VARCHAR
Metric name of the series, e.g. 'system.cpu.user'.
tags MAP(VARCHAR, VARCHAR)
Group-by tags of the series as a MAP (host -> 'web-1'); empty for an ungrouped query.
ts TIMESTAMPTZ
Point timestamp (start of the rollup interval).
value DOUBLE
Point value; NULL where Datadog reports a gap.
scope VARCHAR
The series scope as Datadog prints it, e.g. 'env:prod,host:web-1'.
expression VARCHAR
The expanded query expression that produced the series.
query_index INTEGER
0-based index of the comma-separated query that produced the series.
aggr VARCHAR
Space aggregation: avg, sum, min or max (NULL for raw).
unit VARCHAR
Unit name of the metric, e.g. 'percent' or 'byte'.
interval_seconds BIGINT
Rollup interval of the points, in seconds.
Examples (2)

Average CPU per production host over one hour

SELECT tags['host'] AS host, avg(value) AS avg_cpu
FROM datadog.main.metrics_query('avg:system.cpu.user{env:prod} by {host}', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
GROUP BY host
ORDER BY avg_cpu DESC;

Request counts per minute for one service

SELECT date_trunc('minute', ts) AS minute, sum(value) AS requests
FROM datadog.main.metrics_query('sum:trace.http.request.hits{service:web}.as_count()', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
GROUP BY minute
ORDER BY minute;
Link
spans (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE, max_rows := BIGINT, newest_first := BOOLEAN) 2 examples

Search APM spans in a time window; SQL filters on service/env/resource/status run in Datadog

Positional arguments
query VARCHAR
Datadog search query, e.g. 'service:web status:error'; '*' matches everything.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Named arguments
max_rows := BIGINT
Stop after this many rows; NULL reads the whole window. · default null
newest_first := BOOLEAN
Page from the newest record backwards (with max_rows: the latest N). · default false
Returns columns
span_id VARCHAR
Span id.
trace_id VARCHAR
Trace id the span belongs to.
parent_id VARCHAR
Parent span id ('0' or NULL for a root span).
ts TIMESTAMPTZ
Span start time.
end_ts TIMESTAMPTZ
Span end time.
duration_seconds DOUBLE
Span duration in seconds.
service VARCHAR
Service name.
env VARCHAR
Environment.
host VARCHAR
Host.
resource_name VARCHAR
Resource, e.g. 'GET /api/users'.
operation_name VARCHAR
Operation, e.g. 'http.request'.
span_type VARCHAR
Span type: web, db, cache, http, custom ...
status VARCHAR
'ok' or 'error'.
is_error BOOLEAN
True when status is 'error'.
tags MAP(VARCHAR, VARCHAR)
Span tags as a MAP.
attributes JSON
Custom span attributes (the @path facets), JSON.
Examples (2)

p95 latency and error rate per endpoint of one service

SELECT resource_name, count(*) AS spans,
  quantile_cont(duration_seconds, 0.95) AS p95_s,
  avg(is_error::INT) AS error_rate
FROM datadog.main.spans('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
WHERE service = 'web' AND env = 'prod'
GROUP BY resource_name
ORDER BY p95_s DESC;

Logs correlated with error spans through the trace id

SELECT s.service, s.resource_name, l.message
FROM datadog.main.spans('status:error', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00') s
JOIN datadog.main.logs('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00') l ON l.trace_id = s.trace_id
ORDER BY s.service;
Link
spans_aggregate (query VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE, aggregation := VARCHAR, group_by := VARCHAR, group_limit := BIGINT, metric := VARCHAR, rollup := VARCHAR) 1 example

Aggregate APM spans (count, percentiles ...) by facets, as totals or a timeseries

Positional arguments
query VARCHAR
Datadog search query selecting the records, e.g. 'service:web'; '*' for all.
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Named arguments
aggregation := VARCHAR
count (default), cardinality, sum, min, max, avg, median or pc75..pc99. · default "count"
group_by := VARCHAR
Comma-separated facets to group by, e.g. 'service,status' or '@http.status_code'. · default null
group_limit := BIGINT
Top groups kept per group_by facet, ranked by the aggregate (1 to 10000). · default 10
metric := VARCHAR
Measure to aggregate, e.g. '@duration'; required for every aggregation except count. · default null
rollup := VARCHAR
Bucket width such as '5m' or '1h' for a timeseries (one row per bucket); NULL returns one total per group. · default null
Returns columns
groups MAP(VARCHAR, VARCHAR)
The group-by facet values of the row as a MAP (service -> 'web'); empty without group_by.
ts TIMESTAMPTZ
Bucket start for a timeseries (rollup set); NULL for a total.
value DOUBLE
The aggregate value.
aggregation VARCHAR
The aggregation that produced value, e.g. 'count' or 'pc95'.
metric VARCHAR
The aggregated measure, e.g. '@duration'; NULL for count.
Example

p99 latency per endpoint, computed in Datadog (span durations are in nanoseconds)

SELECT groups['resource_name'] AS endpoint, value / 1e6 AS p99_ms
FROM datadog.main.spans_aggregate('service:web env:prod', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00', group_by := 'resource_name', aggregation := 'pc99', metric := '@duration')
ORDER BY p99_ms DESC;
Link
resources 13 tables · 4 functions

Datadog configuration and records: monitors, SLOs, incidents, dashboards, synthetics, hosts, users.

Schema examples (17)
Examples (17)

Monitors currently alerting, by priority

SELECT id, name, priority
FROM datadog.resources.monitors
WHERE overall_state = 'Alert'
ORDER BY priority NULLS LAST, name;

Hosts alerting on any monitor

SELECT group_tags['host'] AS host,
  list(monitor_name ORDER BY monitor_name) AS monitors
FROM datadog.resources.monitor_groups
WHERE status = 'Alert'
GROUP BY host
ORDER BY host;

Active downtimes and what they mute

SELECT scope, monitor_id, end_at
FROM datadog.resources.downtimes
WHERE status = 'active'
ORDER BY end_at NULLS LAST;

SLOs per team with their targets

SELECT tags['team'] AS team, name, target, timeframe
FROM datadog.resources.slos
ORDER BY team, name;
13 more examples

Mean time to resolve per severity

SELECT severity, count(*) AS incidents,
  avg(time_to_resolve_seconds) / 3600 AS mttr_hours
FROM datadog.resources.incidents
WHERE status = 'resolved'
GROUP BY severity
ORDER BY severity;

Dashboards per author

SELECT author_handle, count(*) AS dashboards
FROM datadog.resources.dashboards
GROUP BY author_handle
ORDER BY dashboards DESC;

Live tests per type and subtype

SELECT type, subtype, count(*) AS tests
FROM datadog.resources.synthetics_tests
WHERE status = 'live'
GROUP BY ALL
ORDER BY tests DESC;

Hosts per environment and agent version

SELECT tags['env'] AS env, agent_version, count(*) AS hosts
FROM datadog.resources.hosts
GROUP BY ALL
ORDER BY env, agent_version;

Hosts per role

SELECT value AS role, count(*) AS hosts
FROM datadog.resources.host_tags
WHERE key = 'role'
GROUP BY role
ORDER BY hosts DESC;

Active users without MFA

SELECT email, name
FROM datadog.resources.users
WHERE status = 'Active' AND NOT service_account AND NOT mfa_enabled
ORDER BY email;

Largest teams

SELECT handle, user_count
FROM datadog.resources.teams
ORDER BY user_count DESC, handle;

Roles by membership

SELECT name, user_count
FROM datadog.resources.roles
ORDER BY user_count DESC, name;

Tier-1 services per team

SELECT team, list(service ORDER BY service) AS services
FROM datadog.resources.services
WHERE tier = '1'
GROUP BY team
ORDER BY team;

October SLI and error budget left for one SLO

SELECT sli_value, target, error_budget_remaining_pct
FROM datadog.resources.slo_history('abc123def456', TIMESTAMPTZ '2026-10-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 00:00:00+00')
WHERE group_name IS NULL;

Widget types used on one dashboard

SELECT w.value->>'$.definition.type' AS widget_type, count(*) AS widgets
FROM datadog.resources.dashboard('abc-def-ghi') d,
     json_each(d.widgets) w
GROUP BY widget_type
ORDER BY widgets DESC;

Success rate and median duration per location for one test

SELECT location, avg(passed::INT) AS success_rate,
  median(duration_ms) AS median_ms
FROM datadog.resources.synthetics_results('abc-123-xyz', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00')
GROUP BY location
ORDER BY success_rate;

Monthly infrastructure host count (99th percentile) over five months

SELECT month, value AS infra_hosts
FROM datadog.resources.usage_summary(DATE '2026-06-01', end_month := DATE '2026-10-01')
WHERE usage_type = 'infra_host_top99p'
ORDER BY month;
Tables
dashboards 2 examples9 cols

Every dashboard: title, layout, author and timestamps.

Columns
idnot null VARCHAR
Dashboard id, e.g. 'abc-def-ghi'.
title VARCHAR
Dashboard title.
description VARCHAR
Dashboard description.
layout_type VARCHAR
'ordered' (timeboard) or 'free' (screenboard).
author_handle VARCHAR
Handle of the author.
is_read_only BOOLEAN
True when only the author and admins may edit.
created_at TIMESTAMP WITH TIME ZONE
When the dashboard was created.
modified_at TIMESTAMP WITH TIME ZONE
When the dashboard was last changed.
url VARCHAR
Link to the dashboard in the Datadog app.
ConstraintsPRIMARY KEY (id)
Examples (2)

Dashboards per author

SELECT author_handle, count(*) AS dashboards
FROM datadog.resources.dashboards
GROUP BY author_handle
ORDER BY dashboards DESC;

Stale dashboards

SELECT title, modified_at
FROM datadog.resources.dashboards
WHERE modified_at < TIMESTAMPTZ '2026-01-01 00:00:00+00'
ORDER BY modified_at;
Link
downtimes 1 example14 cols

Monitor downtimes: scope, target monitor or monitor tags, schedule and status.

Columns
idnot null VARCHAR
Downtime id (UUID).
status VARCHAR
active, scheduled, ended or canceled.
scope VARCHAR
Scope muted, e.g. 'env:staging'.
monitor_id BIGINT
Identifier of the single monitor muted (monitors.id; an id, not a quantity).
monitor_tags VARCHAR[]
Monitor tags selecting the muted monitors, if it targets tags.
message VARCHAR
Downtime message.
start_at TIMESTAMP WITH TIME ZONE
Start of the (current or first) downtime window.
end_at TIMESTAMP WITH TIME ZONE
End of the window; NULL for an indefinite downtime.
is_recurring BOOLEAN
True for a recurring schedule.
schedule JSON
The full schedule (one-time or recurrences), JSON.
created_by VARCHAR
User id of the creator.
created_at TIMESTAMP WITH TIME ZONE
When the downtime was created.
modified_at TIMESTAMP WITH TIME ZONE
When the downtime was last changed.
canceled_at TIMESTAMP WITH TIME ZONE
When the downtime was canceled, if it was.
ConstraintsPRIMARY KEY (id)
Example

Active downtimes and what they mute

SELECT scope, monitor_id, end_at
FROM datadog.resources.downtimes
WHERE status = 'active'
ORDER BY end_at NULLS LAST;
Link
host_tags 1 example4 cols

Every tag of every host, one row per host and tag, split into key and value.

Columns
host_namenot null VARCHAR
Host name (hosts.host_name).
tagnot null VARCHAR
The tag, 'key:value'.
keynot null VARCHAR
Tag key.
valuenot null VARCHAR
Tag value ('' for a bare tag).
ConstraintsPRIMARY KEY (host_name, tag)
Example

Hosts per role

SELECT value AS role, count(*) AS hosts
FROM datadog.resources.host_tags
WHERE key = 'role'
GROUP BY role
ORDER BY hosts DESC;
Link
hosts 2 examples14 cols

Hosts reporting to Datadog with their status, tags, agent version and recent CPU and load.

Columns
host_namenot null VARCHAR
Name the host reports under (the agent hostname), e.g. 'web-1'.
id BIGINT
Numeric Datadog identifier of the host (an id, not a quantity).
aliases VARCHAR[]
Other names of the host.
apps VARCHAR[]
Integrations reporting from the host.
sources VARCHAR[]
Sources of the host: agent, aws, gcp, azure ...
up BOOLEAN
True when the host is reporting.
is_muted BOOLEAN
True when the host is muted.
last_reported_at TIMESTAMP WITH TIME ZONE
Last time the host reported.
tags MAP(VARCHAR, VARCHAR)
Host tags from every source as a MAP.
platform VARCHAR
OS platform, e.g. 'linux'.
agent_version VARCHAR
Datadog Agent version.
cpu_pct DOUBLE
Recent CPU utilisation in percent.
iowait_pct DOUBLE
Recent I/O wait in percent.
load DOUBLE
Recent normalised load (load15 / cores).
ConstraintsPRIMARY KEY (host_name)
Examples (2)

Hosts per environment and agent version

SELECT tags['env'] AS env, agent_version, count(*) AS hosts
FROM datadog.resources.hosts
GROUP BY ALL
ORDER BY env, agent_version;

Busiest hosts

SELECT host_name, cpu_pct, load
FROM datadog.resources.hosts
WHERE up
ORDER BY cpu_pct DESC NULLS LAST
LIMIT 10;
Link
incidents 2 examples20 cols

Datadog incidents with status, severity, impact, timestamps and time-to-resolve metrics.

Columns
incident_idnot null VARCHAR
Incident id (UUID).
incident_number BIGINT
Public incident number shown in the app (#42).
title VARCHAR
Incident title.
status VARCHAR
State: active, stable or resolved.
severity VARCHAR
Severity: SEV-1 (highest) .. SEV-5, or UNKNOWN.
customer_impacted BOOLEAN
True when customers were impacted.
customer_impact_scope VARCHAR
Description of the customer impact.
created_at TIMESTAMP WITH TIME ZONE
When the incident was declared.
detected_at TIMESTAMP WITH TIME ZONE
When the issue was detected.
resolved_at TIMESTAMP WITH TIME ZONE
When the incident was resolved; NULL while open.
modified_at TIMESTAMP WITH TIME ZONE
When the incident record last changed.
time_to_detect_seconds DOUBLE
Seconds from impact start to detection.
time_to_internal_response_seconds DOUBLE
Seconds from detection to the first response.
time_to_repair_seconds DOUBLE
Seconds from detection to repair.
time_to_resolve_seconds DOUBLE
Seconds from creation to resolution.
services VARCHAR[]
Services the incident affects.
teams VARCHAR[]
Teams the incident is assigned to.
commander_user_id VARCHAR
User id of the incident commander.
fields JSON
Every incident field (state, severity, root cause, custom fields), JSON.
url VARCHAR
Link to the incident in the Datadog app.
ConstraintsPRIMARY KEY (incident_id)
Examples (2)

Mean time to resolve per severity

SELECT severity, count(*) AS incidents,
  avg(time_to_resolve_seconds) / 3600 AS mttr_hours
FROM datadog.resources.incidents
WHERE status = 'resolved'
GROUP BY severity
ORDER BY severity;

Open incidents and the services they hit

SELECT incident_number, title, severity, services
FROM datadog.resources.incidents
WHERE status <> 'resolved'
ORDER BY created_at;
Link
monitor_groups 2 examples9 cols

One row per monitor and group (e.g. per host) with that group's state and last trigger times.

Columns
monitor_idnot null BIGINT
Monitor id (monitors.id).
monitor_name VARCHAR
Display name of the monitor (monitors.name).
group_namenot null VARCHAR
Group the state belongs to, e.g. 'host:web-1,env:prod' ('*' for a simple monitor).
group_tags MAP(VARCHAR, VARCHAR)
The group split into a MAP (host -> 'web-1').
status VARCHAR
State of this group: OK, Alert, Warn, No Data ...
last_triggered_at TIMESTAMP WITH TIME ZONE
When the group last triggered.
last_resolved_at TIMESTAMP WITH TIME ZONE
When the group last resolved.
last_nodata_at TIMESTAMP WITH TIME ZONE
When the group last reported no data.
last_notified_at TIMESTAMP WITH TIME ZONE
When the group last sent a notification.
ConstraintsPRIMARY KEY (monitor_id, group_name)
Examples (2)

Hosts alerting on any monitor

SELECT group_tags['host'] AS host,
  list(monitor_name ORDER BY monitor_name) AS monitors
FROM datadog.resources.monitor_groups
WHERE status = 'Alert'
GROUP BY host
ORDER BY host;

Groups of one monitor (fetched by id)

SELECT group_name, status, last_triggered_at
FROM datadog.resources.monitor_groups
WHERE monitor_id = 1001
ORDER BY group_name;
Link
monitors 2 examples14 cols

Datadog monitors with their query, overall state, priority, tags and options.

Columns
idnot null BIGINT
Numeric identifier of the monitor (an id, not a quantity).
name VARCHAR
Monitor name.
type VARCHAR
Monitor type, e.g. 'metric alert', 'log alert', 'service check'.
query VARCHAR
The monitor query.
message VARCHAR
Notification message (with @-mentions).
overall_state VARCHAR
Current overall state: OK, Alert, Warn, No Data, Ignored, Skipped, Unknown.
priority INTEGER
Priority 1 (highest) to 5; NULL when unset.
tags MAP(VARCHAR, VARCHAR)
Monitor tags as a MAP (team -> 'core').
multi BOOLEAN
True for a multi-alert monitor (one state per group).
creator_email VARCHAR
Email of the creator.
created_at TIMESTAMP WITH TIME ZONE
When the monitor was created.
modified_at TIMESTAMP WITH TIME ZONE
When the monitor was last changed.
options JSON
Monitor options (thresholds, notify_no_data, renotify ...), JSON.
url VARCHAR
Link to the monitor in the Datadog app.
ConstraintsPRIMARY KEY (id)
Examples (2)

Monitors currently alerting, by priority

SELECT id, name, priority
FROM datadog.resources.monitors
WHERE overall_state = 'Alert'
ORDER BY priority NULLS LAST, name;

Monitor count per owning team

SELECT tags['team'] AS team, count(*) AS monitors
FROM datadog.resources.monitors
GROUP BY team
ORDER BY monitors DESC;
Link
roles 1 example5 cols

Access roles defined in the organization, with how many users hold each one.

Columns
idnot null VARCHAR
Role id (UUID).
name VARCHAR
Role name, e.g. 'Datadog Admin Role'.
user_count BIGINT
Users holding the role (count).
created_at TIMESTAMP WITH TIME ZONE
When the role was created.
modified_at TIMESTAMP WITH TIME ZONE
When the role was last changed.
ConstraintsPRIMARY KEY (id)
Example

Roles by membership

SELECT name, user_count
FROM datadog.resources.roles
ORDER BY user_count DESC, name;
Link
services 2 examples15 cols

Service catalog definitions: owning team, tier, lifecycle, languages, contacts and links.

Columns
servicenot null VARCHAR
Service name (dd-service), as used in service:<name> tags.
schema_version VARCHAR
Service definition schema version, e.g. 'v2.2'.
team VARCHAR
Owning team handle.
tier VARCHAR
Importance tier, e.g. '1'.
lifecycle VARCHAR
Lifecycle: production, experimental, deprecated ...
application VARCHAR
Application the service belongs to.
type VARCHAR
Service type: web, db, cache, function, custom ...
description VARCHAR
Service description.
languages VARCHAR[]
Programming languages.
tags MAP(VARCHAR, VARCHAR)
Tags declared in the definition, as a MAP.
contacts JSON
Contacts (email, Slack, Teams), JSON.
links JSON
Links (runbooks, docs, repos, dashboards), JSON.
definition JSON
The full service definition, JSON.
last_modified_at TIMESTAMP WITH TIME ZONE
When the definition was last changed.
ingestion_source VARCHAR
Where the definition came from: api, github, ui ...
ConstraintsPRIMARY KEY (service)
Examples (2)

Tier-1 services per team

SELECT team, list(service ORDER BY service) AS services
FROM datadog.resources.services
WHERE tier = '1'
GROUP BY team
ORDER BY team;

Services without an owner

SELECT service, lifecycle
FROM datadog.resources.services
WHERE team IS NULL
ORDER BY service;
Link
slos 1 example16 cols

Service level objectives with their type, targets and tags.

Columns
idnot null VARCHAR
SLO id.
name VARCHAR
SLO name.
description VARCHAR
SLO description.
type VARCHAR
metric, monitor or time_slice.
tags MAP(VARCHAR, VARCHAR)
SLO tags as a MAP.
target DOUBLE
Target of the primary threshold, in percent (e.g. 99.9).
timeframe VARCHAR
Timeframe of the primary threshold: 7d, 30d, 90d, custom.
warning DOUBLE
Warning level of the primary threshold, in percent.
thresholds STRUCT of 3 fields[]
Every threshold (timeframe, target, warning).
STRUCT[] 3 fields
  • timeframeVARCHAR
  • targetDOUBLE
  • warningDOUBLE
monitor_ids BIGINT[]
Identifiers of the monitors behind a monitor-based SLO (monitors.id values).
numerator VARCHAR
Good-events query of a metric SLO.
denominator VARCHAR
Total-events query of a metric SLO.
creator_email VARCHAR
Email of the creator.
created_at TIMESTAMP WITH TIME ZONE
When the SLO was created.
modified_at TIMESTAMP WITH TIME ZONE
When the SLO was last changed.
url VARCHAR
Link to the SLO in the Datadog app.
ConstraintsPRIMARY KEY (id)
Example

SLOs per team with their targets

SELECT tags['team'] AS team, name, target, timeframe
FROM datadog.resources.slos
ORDER BY team, name;
Link
synthetics_tests 1 example13 cols

Synthetic API and browser tests: type, status, locations, frequency and tags.

Columns
public_idnot null VARCHAR
Test public id, e.g. 'abc-123-xyz'.
name VARCHAR
Test name.
type VARCHAR
api, browser or mobile.
subtype VARCHAR
API test subtype: http, ssl, dns, tcp, icmp, multi, grpc, websocket, udp.
status VARCHAR
live or paused.
monitor_id BIGINT
Monitor that alerts on the test (monitors.id).
tags MAP(VARCHAR, VARCHAR)
Test tags as a MAP.
locations VARCHAR[]
Locations the test runs from, e.g. 'aws:eu-central-1'.
tick_every_seconds BIGINT
Run frequency in seconds.
message VARCHAR
Notification message.
creator_email VARCHAR
Email of the creator.
config JSON
Request and assertion configuration, JSON.
url VARCHAR
Link to the test in the Datadog app.
ConstraintsPRIMARY KEY (public_id)
Example

Live tests per type and subtype

SELECT type, subtype, count(*) AS tests
FROM datadog.resources.synthetics_tests
WHERE status = 'live'
GROUP BY ALL
ORDER BY tests DESC;
Link
teams 2 examples9 cols

Teams with handle, description and member count.

Columns
idnot null VARCHAR
Team id (UUID).
name VARCHAR
Team name.
handle VARCHAR
Team handle, used in team:<handle> tags.
summary VARCHAR
One-line summary.
description VARCHAR
Team description (Markdown).
user_count BIGINT
Members (count).
link_count BIGINT
Links on the team page (count).
created_at TIMESTAMP WITH TIME ZONE
When the team was created.
modified_at TIMESTAMP WITH TIME ZONE
When the team was last changed.
ConstraintsPRIMARY KEY (id)
Examples (2)

Largest teams

SELECT handle, user_count
FROM datadog.resources.teams
ORDER BY user_count DESC, handle;

Monitors owned by each team

SELECT t.handle, count(m.id) AS monitors
FROM datadog.resources.teams t
LEFT JOIN datadog.resources.monitors m ON m.tags['team'] = t.handle
GROUP BY t.handle
ORDER BY monitors DESC;
Link
users 2 examples13 cols

Users of the organization with status, MFA, service-account flag and role ids.

Columns
idnot null VARCHAR
User id (UUID).
name VARCHAR
Display name.
handle VARCHAR
Login handle.
email VARCHAR
Email address.
status VARCHAR
Active, Pending or Disabled.
disabled BOOLEAN
True for a disabled user.
verified BOOLEAN
True once the email is verified.
service_account BOOLEAN
True for a service account.
mfa_enabled BOOLEAN
True when multi-factor authentication is on.
title VARCHAR
Job title.
role_ids VARCHAR[]
Ids of the user's roles (roles.id).
created_at TIMESTAMP WITH TIME ZONE
When the user was created.
modified_at TIMESTAMP WITH TIME ZONE
When the user was last changed.
ConstraintsPRIMARY KEY (id)
Examples (2)

Active users without MFA

SELECT email, name
FROM datadog.resources.users
WHERE status = 'Active' AND NOT service_account AND NOT mfa_enabled
ORDER BY email;

Users per role

SELECT r.name AS role, count(*) AS users
FROM datadog.resources.users u,
     unnest(u.role_ids) AS t(role_id)
JOIN datadog.resources.roles r ON r.id = t.role_id
GROUP BY role
ORDER BY users DESC;
Link
Table functions
dashboard (dashboard_id VARCHAR) 1 example

One Datadog dashboard's full definition: widgets, template variables and layout as JSON

Arguments
dashboard_id VARCHAR
Dashboard id (dashboards.id), e.g. 'abc-def-ghi'.
Returns columns
id VARCHAR
Dashboard id.
title VARCHAR
Dashboard title.
description VARCHAR
Dashboard description.
layout_type VARCHAR
'ordered' or 'free'.
tags VARCHAR[]
Dashboard tags (team:...).
widget_count BIGINT
Number of top-level widgets (count).
widgets JSON
The widget definitions, JSON array.
template_variables JSON
Template variables, JSON array.
definition JSON
The whole dashboard definition as returned by the API, JSON.
author_handle VARCHAR
Handle of the author.
created_at TIMESTAMPTZ
When the dashboard was created.
modified_at TIMESTAMPTZ
When the dashboard was last changed.
url VARCHAR
Link to the dashboard in the Datadog app.
Example

Widget types used on one dashboard

SELECT w.value->>'$.definition.type' AS widget_type, count(*) AS widgets
FROM datadog.resources.dashboard('abc-def-ghi') d,
     json_each(d.widgets) w
GROUP BY widget_type
ORDER BY widgets DESC;
Link
slo_history (slo_id VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE) 1 example

SLI value and remaining error budget of one SLO over a time window, overall and per group

Arguments
slo_id VARCHAR
SLO id (slos.id).
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Returns columns
slo_id VARCHAR
SLO id.
group_name VARCHAR
Monitor group for a grouped SLO; NULL for the overall row.
from_ts TIMESTAMPTZ
Start of the evaluated window.
to_ts TIMESTAMPTZ
End of the evaluated window.
type VARCHAR
SLO type: metric, monitor or time_slice.
sli_value DOUBLE
Measured SLI over the window, in percent.
target DOUBLE
Target of the primary threshold, in percent.
error_budget_remaining_pct DOUBLE
Share of the error budget left: (sli - target) / (100 - target) * 100; negative when exhausted.
good_events DOUBLE
Metric SLO: numerator sum over the window (count).
total_events DOUBLE
Metric SLO: denominator sum over the window (count).
Example

October SLI and error budget left for one SLO

SELECT sli_value, target, error_budget_remaining_pct
FROM datadog.resources.slo_history('abc123def456', TIMESTAMPTZ '2026-10-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 00:00:00+00')
WHERE group_name IS NULL;
Link
synthetics_results (public_id VARCHAR, from_time TIMESTAMP WITH TIME ZONE, to_time TIMESTAMP WITH TIME ZONE) 1 example

Recent results of one synthetic test in a time window, one row per run and location

Arguments
public_id VARCHAR
Test public id (synthetics_tests.public_id).
from_time TIMESTAMP WITH TIME ZONE
Start of the time window, inclusive, e.g. 2026-11-01 00:00 UTC.
to_time TIMESTAMP WITH TIME ZONE
End of the time window.
Returns columns
public_id VARCHAR
Test public id.
result_id VARCHAR
Result id.
check_time TIMESTAMPTZ
When the run happened.
location VARCHAR
Location the run came from, e.g. 'aws:eu-central-1'.
passed BOOLEAN
True when every assertion passed.
status INTEGER
Result status code: 0 passed, 1 failed, 2 no data.
duration_ms DOUBLE
Total run time in milliseconds.
http_status_code INTEGER
HTTP status of an HTTP API test.
Example

Success rate and median duration per location for one test

SELECT location, avg(passed::INT) AS success_rate,
  median(duration_ms) AS median_ms
FROM datadog.resources.synthetics_results('abc-123-xyz', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00')
GROUP BY location
ORDER BY success_rate;
Link
usage_summary (start_month DATE, end_month := DATE) 1 example

Monthly Datadog usage metering per usage field (needs usage_read on the parent org)

Positional arguments
start_month DATE
First month to report; any day within it works, e.g. 2026-09-01.
Named arguments
end_month := DATE
Month the report ends with, sent as Datadog's end_month; NULL reports up to the current month. · default null
Returns columns
month DATE
First day of the month.
usage_type VARCHAR
Usage field, e.g. 'infra_host_top99p', 'logs_indexed_logs_usage_sum'.
value DOUBLE
Usage value for the month (hosts, bytes, events ... per the field's unit).
Example

Monthly infrastructure host count (99th percentile) over five months

SELECT month, value AS infra_hosts
FROM datadog.resources.usage_summary(DATE '2026-06-01', end_month := DATE '2026-10-01')
WHERE usage_type = 'infra_host_top99p'
ORDER BY month;
Link

Credentials

The secret type datadog declares, as reported by the worker itself.

datadog

How to get these credentials

Connection to one Datadog organization: an API key, an application key with read scopes, and the site the organization lives on (datadoghq.com by default).

secret.sql
CREATE SECRET datadog (
    TYPE datadog,
    api_key   '<DATADOG_API_KEY>',  -- required, secret
    app_key   '<APP_KEY>',  -- required, secret
    site      '<site>',
    base_url  '<base_url>',
    timeout   '<timeout>',
    page_size '<page_size>'
);
Key Type Required Description
api_key secret VARCHAR Yes Datadog API key (Organization settings, API keys).
app_key secret VARCHAR Yes Datadog application key (Organization settings, Application keys). Scope it to read-only permissions such as metrics_read, logs_read_data, apm_read, monitors_read, incident_read.
site VARCHAR No Datadog site: 'datadoghq.com' (US1, default), 'us3.datadoghq.com', 'us5.datadoghq.com', 'datadoghq.eu', 'ap1.datadoghq.com', 'ap2.datadoghq.com' or 'ddog-gov.com' (aliases us1, us3, us5, eu, ap1, ap2, gov).
base_url VARCHAR No Override the API origin, e.g. a proxy or a local fixture server 'http://127.0.0.1:8126'. Default: https://api.<site>.
timeout DOUBLE No Per-request timeout in seconds (default 60).
page_size BIGINT No Rows requested per page from search endpoints (logs, spans, events, audit), 1 to 1000 (default 1000). List endpoints cap it at their own maximum.

Needed by slo_historydashboardsynthetics_resultsusage_summarymetrics_querymetric_metadatametric_tagslogslogs_aggregatespansspans_aggregateevents and 1 more functions

Create the secret in the same session, after attaching datadog — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

Average CPU per production host over one hour

SELECT tags['host'] AS host, avg(value) AS avg_cpu
FROM datadog.main.metrics_query('avg:system.cpu.user{env:prod} by {host}', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
GROUP BY host
ORDER BY avg_cpu DESC

Uses metrics_query

Type and unit of one metric

SELECT type, unit, per_unit
FROM datadog.main.metric_metadata('system.net.bytes_rcvd')

Uses metric_metadata

Tag cardinality per key for one metric

SELECT key, count(*) AS distinct_values
FROM datadog.main.metric_tags('system.cpu.user')
GROUP BY key
ORDER BY distinct_values DESC

Uses metric_tags

Production error logs per service for one day (status and env run in Datadog)

SELECT service, count(*) AS errors
FROM datadog.main.logs('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00')
WHERE status = 'error' AND env = 'prod'
GROUP BY service
ORDER BY errors DESC

Uses logs

Log volume per service and status for one day, counted in Datadog

SELECT groups['service'] AS service, groups['status'] AS status,
  value AS logs
FROM datadog.main.logs_aggregate('env:prod', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-02 00:00:00+00', group_by := 'service,status')
ORDER BY logs DESC

Uses logs_aggregate

p95 latency and error rate per endpoint of one service

SELECT resource_name, count(*) AS spans,
  quantile_cont(duration_seconds, 0.95) AS p95_s,
  avg(is_error::INT) AS error_rate
FROM datadog.main.spans('*', TIMESTAMPTZ '2026-11-01 00:00:00+00', TIMESTAMPTZ '2026-11-01 01:00:00+00')
WHERE service = 'web' AND env = 'prod'
GROUP BY resource_name
ORDER BY p95_s DESC

Uses spans

38 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using the datadog worker, how many error-status logs did each service emit in env prod between 2026-11-01 00:00 and 2026-11-02 00:00 UTC?
  • Which Datadog monitors are currently in the Alert state? Give their ids and names.
  • What was the average of avg:system.cpu.user{env:prod} by {host} per host between 2026-11-01 00:00 and 01:00 UTC?
  • What is the mean time to resolve, in hours, of resolved Datadog incidents per severity?
  • Which resource of the web service had the slowest single span between 2026-11-01 00:00 and 01:00 UTC, and how long did it take in seconds?
  • Using Datadog log analytics (computed in Datadog, not by reading logs), count prod logs per status between 2026-11-01 00:00 and 2026-11-02 00:00 UTC.

Datadog is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.