Slo Defined + Datadog Collector
Enforce Slo Defined using data collected by Datadog Collector. Automatically check operational readiness standards on every PR.
How Datadog Collector Powers This Guardrail
The Datadog Collector gathers metadata from your service catalog systems. This data flows into Lunar's Component JSON, where the Slo Defined guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the Datadog Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/datadog@v1.0.5
# with: ...
# Step 2: Enable the Observability Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/observability@v1.0.5
include: [slo-defined]
# with: ...
What Datadog Collector Collects
This collector gathers the following data that the Slo Defined guardrail evaluates.
service
Queries the Datadog REST API for the component's monitors, dashboard,
and SLOs. Discovers the Datadog service tag from the component's
datadog/service-name meta annotation (typically set by a
company-specific cataloger via
lunar catalog component --meta datadog/service-name <name>), or
falls back to the explicit service_name input for static cases.
Optionally resolves a dashboard UUID from the datadog/dashboard-id
meta or the dashboard_id input — dashboards in Datadog are not
universally tagged with service:, so they must be mapped explicitly.
Monitors (via /api/v1/monitor) and SLOs (via /api/v1/slo) are
filtered by the service:<name> tag; dashboard is fetched by UUID
when set. Writes normalized data to .observability.dashboard,
.observability.alerts (monitors), .observability.slo, and
.observability.source, with raw API responses under
.observability.native.datadog.api.
repo-files
Walks the component repository looking for Datadog-as-code JSON files
by content fingerprint. Dashboards are identified by a top-level
widgets array plus a layout_type field (the shape produced by
Datadog's dashboard JSON export and the datadog_dashboard_json
Terraform resource). Monitors are identified by a top-level object
with type (e.g. metric alert, query alert, service check),
query, and name fields. Users can narrow the scan by setting the
find_command input (e.g. to restrict to a datadog/ directory); by
default the full repo is walked. Writes each matching file's raw JSON
(plus its repo path) into
.observability.native.datadog.repo_dashboards and
.observability.native.datadog.repo_monitors for users to build
custom policies against. This sub-collector does not write to
normalized .observability.dashboard / .observability.alerts paths
— the API sub-collector owns those; repo files only surface raw
content.
Example Data Flow
Here's an example of the data that Datadog Collector writes to the Component JSON, which Slo Defined then evaluates.
{
"observability": {
"source": {
"tool": "datadog",
"integration": "api"
},
"dashboard": {
"id": "abc-123-def",
"exists": true,
"url": "https://app.datadoghq.com/dashboard/abc-123-def"
},
"alerts": {
"configured": true,
"count": 7
},
"slo": {
"defined": true,
"count": 2,
"has_error_budget": true
},
"native": {
"datadog": {
"api": {
"service_tag": "payment-api",
"monitors": [ "...list of Datadog monitor objects..." ],
"dashboard": { "...full Datadog dashboard API response..." },
"slos": [ "...list of SLO objects..." ]
},
"repo_dashboards": [
{
"path": "datadog/payment-api-overview.json",
"dashboard": { "title": "Payment API", "layout_type": "ordered", "widgets": [] }
}
],
"repo_monitors": [
{
"path": "datadog/monitors/latency.json",
"monitor": { "name": "High p99 latency", "type": "metric alert", "query": "avg(last_5m):..." }
}
]
}
}
}
}
Configuration Options
Datadog Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
datadog_site |
Optional |
datadoghq.com
|
Datadog site (e.g. `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`). Used to build API URLs and dashboard links. Defaults to the US1 site. |
service_name |
Required | — | Datadog service tag value (e.g. `payment-api`). Optional if the component has a `datadog/service-name` meta annotation set by a cataloger. Monitors and SLOs are filtered by `service:<name>`. |
dashboard_id |
Required | — | Datadog dashboard UUID (e.g. `abc-123-def`). Optional if the component has a `datadog/dashboard-id` meta annotation. Dashboards in Datadog are not universally tagged with `service:`, so they must be mapped explicitly. |
find_command |
Optional |
find . -type f -name '*.json'
|
Command used by the `repo-files` sub-collector to enumerate candidate JSON files (must output one path per line). Narrow this to restrict the scan to a subdirectory, e.g. `find ./datadog -type f -name '*.json'`. |
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 200+ built-in guardrails.