Observability Guardrails
Enforce baseline observability for production services. Verify each service has a linked monitoring dashboard, at least one alert rule configured, and an SLO defined. Works with any observability-category collector (Grafana, Datadog, etc.) via the tool-agnostic .observability paths.
observability to your lunar-config.yml:uses: github://earthly/lunar-lib/policies/observability@v1.0.5
Included Guardrails
This policy includes 3 guardrails that enforce standards for your operational readiness.
dashboard-exists
Verifies that the service has a linked monitoring dashboard by checking .observability.dashboard.exists is true. Fails if observability data is present but .observability.dashboard.exists is false (the UID is registered but the dashboard is gone in Grafana). Skips cleanly when no observability source has written data for this component.
alerts-configured
Verifies that at least one alert rule is configured for the service by checking .observability.alerts.configured is true. Fails if alerting data is present but no rules are configured. Skips cleanly when no observability source has written data for this component. For Datadog, "monitors" map to this check — Datadog monitors are normalized to .observability.alerts.
slo-defined
Verifies that at least one Service Level Objective is defined for the service by checking .observability.slo.defined is true. Fails if observability data is present but no SLOs are configured. Skips cleanly when no observability source has written data for this component. SLO data is provided by collectors that support SLOs (e.g. Datadog). Grafana-only deployments will skip this check unless SLO data is populated from another source.
How Guardrails Fit into Lunar
Lunar guardrails define your engineering standards as code. They evaluate data collected by integrations and produce pass/fail checks with actionable feedback.
Policies support gradual enforcement—from silent scoring to blocking PRs or deployments—letting you roll out standards at your own pace without disrupting existing workflows.
Learn How Lunar Works →Example Evaluated Data
This policy evaluates structured metadata from the Component JSON. Here's an example of the data it checks:
{
"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
}
}
}
Required Integrations
This policy evaluates data gathered by one or more of the following integration(s).
Make sure to enable them in your lunar-config.yml.
Documentation
View on GitHubObservability Guardrails
Enforce baseline observability standards for production services: linked monitoring dashboard, configured alert rules, and defined Service Level Objectives.
Overview
This policy validates that each service has a linked monitoring dashboard, at least one alert rule configured, and at least one SLO defined. It reads from the tool-agnostic .observability category, so the same checks work whether the data comes from Grafana, Datadog, or another provider. For Datadog, "monitors" normalize to .observability.alerts and are covered by alerts-configured.
Policies
This plugin provides the following policies (use include to select a subset):
| Policy | Description |
|---|---|
dashboard-exists |
Verifies a monitoring dashboard is linked to the service |
alerts-configured |
Verifies at least one alert rule (Datadog monitor, Grafana alert, etc.) is configured |
slo-defined |
Verifies at least one Service Level Objective is defined for the service |
Required Data
This policy reads from the following Component JSON paths:
| Path | Type | Provided By |
|---|---|---|
.observability.dashboard.exists |
boolean | grafana, datadog (or any observability-category collector) |
.observability.alerts.configured |
boolean | grafana, datadog |
.observability.slo.defined |
boolean | datadog (collectors that support SLOs) |
Note: Ensure a collector that writes to the .observability category is configured before enabling this policy. The slo-defined check requires a collector that populates .observability.slo (e.g. datadog); in Grafana-only deployments it will skip unless SLO data is provided separately.
Installation
Add to your lunar-config.yml:
policies:
- uses: github://earthly/lunar-lib/policies/observability@v1.0.0
on: ["domain:your-domain"]
enforcement: report-pr
# include: [dashboard-exists] # Only run specific checks
Examples
Passing Example
{
"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 }
}
}
Failing Example
{
"observability": {
"source": { "tool": "datadog", "integration": "api" },
"dashboard": { "id": "abc-123-def", "exists": false },
"alerts": { "configured": false, "count": 0 },
"slo": { "defined": false, "count": 0 }
}
}
Failure message (dashboard-exists): "No monitoring dashboard is linked for this service"
Remediation
When this policy fails, you can resolve it by:
- dashboard-exists: Create or link a monitoring dashboard for the service. For Grafana, register the dashboard UID on the component via
lunar catalog component --meta grafana/dashboard-uid <uid>. For Datadog, setdatadog/dashboard-idvialunar catalog component --meta datadog/dashboard-id <uuid>. - alerts-configured: Create at least one alert rule (Grafana alert in the service's dashboard folder, Datadog monitor tagged with the service, or the equivalent construct in your monitoring tool).
- slo-defined: Create at least one Service Level Objective for the service (Datadog SLO tagged with the service, Grafana SLO, or the equivalent in your SLO platform).
Open Source
This policy is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.
Common Use Cases
Explore how individual guardrails work with specific integrations.
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.