Skip to main content

datadog slo overrides CLI

Version Python License uv Ruff ty Pylint complexipy pyscn pytest tox ProperDocs pre-commit Conventional Commits Changelog Documentation: Diátaxis Build Coverage pyscn quality

CLI to set overrides idempotently for multiple SLO's

Usage

Set Datadog SLO corrections ("SLO overrides") on many SLOs at once, selected by tag. A correction excludes a time window from an SLO's error budget (e.g. for planned downtime); this tool is the bulk, idempotent, scriptable way to apply them.

Install

uv tool install datadog_slo_overrides_cli   # global `datadog-slo-overrides` command
# or run without installing:
uvx --from datadog_slo_overrides_cli datadog-slo-overrides --help
# or, from a checkout:
uv run datadog-slo-overrides --help

Check the installed version with datadog-slo-overrides --version.

Commands

Command What it does
set Preview (default) or --apply corrections (overrides) to every SLO matching the tags.
list Report each matching SLO's monitor downtime in a window, net of the overrides that excuse it, with uptime percentages.
init-config Write a starter config of non-secret defaults.
init-envrc Write a starter .envrc for optional, direnv-managed credential loading.
commands list Print a tree of every command this CLI provides.

Credentials

The tool never stores credentials. They are resolved in this order (first wins):

  1. --api-key / --app-key flags
  2. DD_API_KEY / DD_APP_KEY environment variables
  3. an optional .envrc in the config dir, loaded via direnv

direnv-loaded values can never override a flag or a real environment variable.

Optional direnv setup (keep secret-fetching logic in a file that direnv's approval model governs, rather than the tool executing shell itself):

datadog-slo-overrides init-envrc                 # writes ~/.config/datadog-slo-overrides/.envrc
# it pre-fills DD_API_KEY / DD_APP_KEY exports; review and adjust the source if needed, then:
direnv allow ~/.config/datadog-slo-overrides

If the .envrc is present but unapproved, or doesn't export the keys, the tool prints an actionable hint instead of failing silently. The config dir honours XDG_CONFIG_HOME.

Selecting SLOs

  • --tag key:value — repeat to require several tags. One tag is sent to Datadog's (single-tag) server query; the rest are ANDed client-side.
  • --tags-query "<raw>" — a raw single-tag Datadog query, used as-is instead of --tag.

Idempotency strategies

set is idempotent: re-running the same command never creates duplicate corrections. --strategy controls when an existing correction counts as already covering your window:

--strategy Skips (creates nothing) when…
skip-if-covered (default) your window is fully inside an existing correction
skip-if-overlap any existing correction overlaps your window (may leave gaps)
skip-if-exact an existing correction matches your window exactly

Examples

Preview which SLOs would be corrected (dry run — nothing is written):

datadog-slo-overrides set --tag app:gitlab --tag customer:sbp \
    --start 2026-06-10T22:00 --end 2026-06-11T00:00

Apply a 2-hour scheduled-maintenance correction:

datadog-slo-overrides set --tag app:gitlab --tag customer:sbp \
    --start 2026-06-10T22:00 --end 2026-06-11T00:00 \
    --category "Scheduled Maintenance" --description "DB maintenance" \
    --apply

When a matched SLO is already covered, it is skipped rather than duplicated:

Already satisfied under --strategy skip-if-covered (will skip): 1
  SBP - SLO monitor for the sbp gitlab Website  (fbb8a2c3…)  -> correction d9e08dd2-…

DRY RUN — would create 0, skip 1 already present. Re-run with --apply to write.

Configuration file

init-config writes non-secret defaults (site, timezone, category, strategy) to ~/.config/datadog-slo-overrides/config.toml. CLI flags override the config, which overrides the built-in defaults. Credentials are never read from this file.

datadog-slo-overrides init-config

Run datadog-slo-overrides set --help for the full list of options.

Reporting downtime

list reports, for each matching SLO, the downtime that still counts against it. Each backing monitor's alerting periods are reconstructed from its Datadog alert/recovery events, the SLO is treated as impaired whenever any of its monitors is alerting, and the windows of every correction (override) on that SLO — including the occurrences of a recurring one — are subtracted. What remains is reported with its uptime percentage for the window. The window defaults to the start of the current month through now; set --start/--end to change it. Tag selection is optional (omit both --tag and --tags-query to report every SLO).

# Net downtime this month, for SLOs tagged app:gitlab:
datadog-slo-overrides list --tag app:gitlab

# A specific window, showing only the SLOs that still have downtime left:
datadog-slo-overrides list --start 2026-08-01T00:00 --end 2026-09-01T00:00 --only-downtime
Tags query : app:gitlab
Window     : 2026-08-01 00:00:00 → 2026-08-31 00:00:00 UTC
Rule       : Datadog monitor alert periods (union: any backing monitor alerting), minus SLO corrections — for a multi-monitor SLO this need not equal Datadog's own SLI
Matched    : 2 SLO(s)
Events     : 4 fetched, 4 usable transition(s)

SBP - SLO monitor for the sbp gitlab Website  (fbb8a2c3…)
  monitors: 12345
  raw 2h 4m 58s - excluded 1h = net 1h 4m 58s
  uptime 99.850% (99.711% before corrections)
  • 2026-08-10 03:00:00 → 2026-08-10 04:00:00  (1h)
  • 2026-08-24 17:47:00 → 2026-08-24 17:51:58  (4m 58s)

Instants are rendered to the second, because monitor transitions land on arbitrary seconds. A correction that only partly overlaps an outage trims it rather than excusing it whole, and an SLO whose downtime was entirely excused says so explicitly — it is not silently identical to one that never failed. --only-downtime hides the clean SLOs and reports how many were hidden.

How to read it, and what it cannot tell you

The percentage answers "was the service impaired". It is not a reproduction of the figure on the SLO's own Datadog page: for an SLO backed by several monitors this unions their bad time, where Datadog aggregates its SLI differently. Treat a disagreement there as expected, not as a bug.

Because a silently empty result is indistinguishable from a flawless month, the report states its own evidence and refuses to certify uptime it cannot back:

  • The Events line reports how many events were fetched and how many became usable transitions. If events came back but none were readable as state changes, the command says so on stderr and exits 1 rather than printing a page of 100%s.
  • A Monitors line appears when some backing monitors produced no transitions at all in the window. Those read as fully up by absence of evidence — worth knowing if a monitor has been red longer than the week of history the report looks back over.
  • Events are fetched in day-sized slices, and a slice that comes back at the API's page cap is halved and retried; if one still saturates, a warning says the report understates downtime.
  • Ignored events are counted by reason (no monitor, no timestamp, unrecognised transition, out-of-range timestamp) and reported on stderr.

Other limits worth knowing: only type: monitor SLOs link to monitors (via monitor_ids), so metric and time-slice SLOs show no monitor downtime; a monitor in WARN is not counted as down; a future --end is pulled back to now so unelapsed time cannot pad the percentage; and a recurring correction with no duration is skipped with a warning rather than having one inferred.

Command tree

datadog-slo-overrides commands list

Prints a tree of every command the CLI provides.

Developing further

Development flow as Paleofuturistic Python

Prerequisite: uv

Setup

  • Fork and clone this repository.
  • On first run of any workflow command, the bootstrap step will prompt to install pre-commit hooks.

Workflow

All commands are invoked via ./workflow.cmd <namespace>.<task>:

Command Description
./workflow.cmd format Format code and sort imports
./workflow.cmd lint Run all linters (ruff, pylint, ty, complexipy, commitizen)
./workflow.cmd test Run all tests (pytest)
./workflow.cmd build Run security checks and build the package
./workflow.cmd release -i <type> Bump version, tag, push, build, publish, and upload SBOM
./workflow.cmd quality Run code quality analysis (pyscn)
./workflow.cmd secure Run security audit and generate SBOM
./workflow.cmd document Build and view documentation (properdocs)
./workflow.cmd develop.pre-commit Run all pre-commit hooks on the codebase
./workflow.cmd bootstrap --force Re-run the development environment setup

Development cycle

  • Add dependencies: uv add some_lib_you_need
  • Develop (optional, tinker: uvx --with-editable . ptpython)
  • Format: ./workflow.cmd format
  • Lint: ./workflow.cmd lint
  • Test: ./workflow.cmd test
  • Build: ./workflow.cmd build
  • Review docs: ./workflow.cmd document
  • Make a pull request.

Release files for datadog_slo_overrides_cli 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datadog_slo_overrides_cli 0.2.2
File Size Uploaded
datadog_slo_overrides_cli-0.2.2.tar.gz 58.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datadog_slo_overrides_cli 0.2.2
File Interpreter ABI Platform
datadog_slo_overrides_cli-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 115.9 kB

Release files / datadog_slo_overrides_cli-0.2.2.tar.gz

Download URL datadog_slo_overrides_cli-0.2.2.tar.gz
Size 58.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8ddaad1e378483f71824ba796785b1a77a6581945e0e6c33ae3bc64800464c6d
BLAKE2b-256 checksum
How to use checksums
e2a7ce7098408f0d95678878e403ba9538d8b717e41ba466ec17d6c8cc85b69d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / datadog_slo_overrides_cli-0.2.2-py3-none-any.whl

Download URL datadog_slo_overrides_cli-0.2.2-py3-none-any.whl
Size 57.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
492c15dbbc92978c4f880ae36b9dbea17f6e205a480b997894775d8d34e0a79c
BLAKE2b-256 checksum
How to use checksums
dfe56678641f74e72caca512777bf33140e2ae5f52af910cc03c1f187bd56236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page