Skip to content

abt-datadog-tools

abt-datadog-tools is a first-party abt package for Datadog, built on the pup CLI. It has six tools for everyday investigation (logs, metrics, monitors, traces, incidents) and generic read and write tools for the 80+ other Datadog API domains.

Package id: abt-datadog-tools ยท Shorthand: datadog

Requires pup >=2.0.0,<3.0.0 on PATH (install). The package reads pup agent schema, which marks every command read_only: true|false, to decide what each tool may run. Other pup versions are rejected.

Tools

Component Tool Access
observability datadog_logs_search read
observability datadog_logs_aggregate read
observability datadog_metrics_query read
observability datadog_monitors_search read
observability datadog_traces_search read
observability datadog_incidents_list read
observability datadog_read read
mutations datadog_write write
abt docs package datadog --project-root .   # same table from abt_package.yaml

In agent frontmatter, tools use datadog__<tool> (double underscore):

tools:
  - datadog__datadog_logs_search
  - datadog__datadog_read
  - datadog__datadog_write    # needs allow_writes

datadog_write needs allow_writes, globally or per component:

config:
  packages:
    abt-datadog-tools:
      allow_writes: false
      components:
        mutations:
          allow_writes: true

Dedicated tools

Typed parameters; the model needs no flag syntax.

Tool Parameters Notes
datadog_logs_search query, start="1h", end="now", limit=10 (1-100), sort="desc", storage="auto", cursor="" Log events, newest first.
datadog_logs_aggregate query, compute="count", group_by="", start, end, limit=10 (1-100), interval="" Counts and distributions. A non-empty interval returns a timeseries.
datadog_metrics_query query, start="1h", end="now" <agg>:<metric>{<scope>} by {<group>}, optionally .rollup(avg, 300).
datadog_monitors_search query="", page=0, per_page=10 (1-50) Org-wide facet counts are dropped.
datadog_traces_search query="*", start, end, limit=5 (1-100), sort="-timestamp", cursor="" APM spans. Durations are in nanoseconds.
datadog_incidents_list query="", limit=50 (1-100) Active incidents unless the query says otherwise, e.g. state:resolved.

Times take relative values (15m, 1h, 7d), now, RFC3339 or Unix time.

Generic tools

datadog_read(domain: str, command: str = "", arguments: list[str] | None = None) -> str
datadog_write(domain: str, command: str = "", arguments: list[str] | None = None) -> str

arguments holds one token per element: flags as --name=value, positional values as their own tokens, e.g. ["12345678"] for monitors get.

There is no help tool. A bad call is rejected with what would work:

Call Answer
empty or unknown domain the domains the tool may use
known domain, empty or unknown command that domain's commands (read commands for datadog_read, write commands for datadog_write)
unknown flag the command's arguments and flags, with a close match
datadog_read(domain="monitors", command="get", arguments=["12345678"])
datadog_write(domain="monitors", command="update", arguments=["12345678", "--file=/work/monitor.json"])
datadog_write(domain="downtime", command="cancel", arguments=["<downtime_id>"])

Writing

  • datadog_write lists and accepts write commands only: datadog_write(domain="monitors") shows what can change.
  • Commands on an existing object take its id as a positional argument.
  • Create and update commands (231 of the 415 write commands in pup 2.4.1) take a JSON body from --file=<path>. The agent needs a tool that can write that file.
  • Calls run with --yes because nothing can answer a prompt, so a call executes as soon as the model makes it. Read the object with datadog_read first.
  • An HTTP 403 means the application key lacks the write scope. It is reported as a credentials problem and not retried.

Results

pup answers with a {status, data, metadata} envelope, which the tools return minified. When metadata.truncated is true, the result ends with a [MORE RESULTS] note: pass metadata.next_cursor as cursor where the tool has one, or follow metadata.next_action. A response over 75,000 characters (about 25k tokens) is cut with a note on how to narrow the request. Errors start with [ERROR]; HTTP 401, 403 and 429 become short messages that name the command.

Safety

Every tool runs pup --output json <domain> <command> <arguments> through the shared abt.packages.cli_runner.run_argv (no shell, explicit environment, timeout, output cap). Read tools add --read-only; write tools add --yes.

  • Refused domains. api, acp, alias, auth, agent, completions, extension, runbooks, skills, api-keys, app-keys, authn-mappings, organizations, users, data-deletion, setup, snapshots and format are refused regardless of allow_writes. pup marks several of them read_only: true although they run arbitrary HTTP methods or local code, so that label alone is not a safe boundary.
  • Mislabeled mutations. pup labels some mutations read_only: true, and its own --read-only guard trusts the label. In 2.4.1 these are security findings mute, llm-obs datasets batch-update|clone|restore, rum playlists sessions bulk-remove and apm adaptive-sampling set-allotment. A command whose name contains create, update, delete, remove, mute, unmute, restore, clone or set counts as a write whatever its label says, which also covers mislabels in later releases.
  • Flags. Only long flags the command declares are accepted; short flags such as -n are rejected. --output, --yes, --org, --read-only, --no-envelope and --jq are reserved: --jq runs inside pup and can read the process environment, including the API keys. --file and --output-file are refused on datadog_read.
  • File access. datadog_write accepts --file, so a model can pick any host path to send as a request body. Grant it only to agents you trust.
  • Untrusted content. Log, event and span content is input to the model and goes to the model provider. Do not combine datadog_write with a prompt that follows instructions found in logs.

Installation

# abt_packages.yml
packages:
  - git: https://github.com/getyourguide/abt-core.git
    revision: main
    subdirectory: packages/abt-datadog-tools
abt deps

Credentials

API key and application key. The package never runs pup auth login.

# profiles.yaml
default:
  target: dev
  outputs:
    dev:
      credentials:
        datadog:
          api_key: "{{ env_var('DD_API_KEY') }}"
          app_key: "{{ env_var('DD_APP_KEY') }}"
          site: datadoghq.com   # optional, defaults to datadoghq.com

Every pup call, schema fetches included, runs with an empty HOME and DD_TOKEN_STORAGE=file, so a cached pup auth login session or pup config cannot override these keys. DD_ACCESS_TOKEN, DD_ORG, PUP_FILTER, PUP_NO_ENVELOPE, PUP_OUTPUT and DD_OUTPUT from the host environment are blanked. A key without the scope for a command gets an HTTP 403, reported as a credentials problem that retrying will not fix.

Notes

  • APM durations are in nanoseconds (1 s = 1000000000).
  • A log event or span is 3-5 KB, so the search tools default to 5-10 results. Page with cursor rather than raising limit.
  • Prefer datadog_logs_aggregate to fetching logs and counting them.
  • Metric points arrive at their native resolution (often 10 s). Append .rollup(avg, 300) to the query for longer ranges.

Example

tools:
  - datadog__datadog_logs_aggregate
  - datadog__datadog_metrics_query
  - datadog__datadog_read
datadog_logs_aggregate(query="service:checkout status:error", group_by="resource_name", start="4h")
datadog_metrics_query(query="avg:system.cpu.user{env:prod} by {host}", start="1h")
datadog_read(domain="monitors", command="get", arguments=["12345678"])

Environment variables

Variable Default Description
ABT_TOOL_MAX_OUTPUT_BYTES 500 KB Per-tool output cap in bytes. The package also caps responses at 75,000 characters.

See also