# Prometheus and Datadog integration

Integrations / Observability. Breadcrumb: [Home](https://osty.dev/) / [Integrations](https://osty.dev/integrations) / Prometheus and Datadog

`osty-edge` reads canary health from Prometheus or Datadog before it promotes a rollout. It compares the canary's error rate, p99 latency and OOM kills with a pre-deploy baseline, waits for at least 50 requests before judging rates, and rolls back on a breach. Without a bound provider, automated rollouts fall back to `VERIFIED_PR`.

Table: Canary outcomes `osty-edge` returns (ADR-0021)

| Outcome | When | What happens next |
| --- | --- | --- |
| `PROMOTE` | The soak is complete, at least `minRequestCount` requests arrived, and error-rate and p99 deltas are within policy. | The wave continues. |
| `CONTINUE_SOAK` | The soak is still running and no threshold is breached. | The edge keeps observing. |
| `ROLLBACK` | Any OOM kill under `zeroOOMKills`, or an error-rate or p99 delta above policy. | The previous digest is redeployed and the wave halts until an operator approves. |
| `INSUFFICIENT_TRAFFIC_HOLD` | The soak finished with zero OOM kills but fewer than `minRequestCount` requests. | The wave pauses for operator promotion or an extended soak. |
| `NO_OBSERVABILITY_PROVIDER` | The workload has no binding in the observability config. | Automated rollout falls back to `VERIFIED_PR`. |

Validate the canary gates in policy:

```bash
osty policy validate .osty/policy.yaml
```

## What does the observability config look like?

The observability config is a separate YAML file on the edge, not part of `.osty/policy.yaml`. Unknown fields are rejected. `providers` lists named Prometheus or Datadog backends, and `workloads` binds each Osty workload key to one provider and a selector. Secrets are never written in the file: `bearerTokenEnv`, `apiKeyEnv` and `appKeyEnv` name environment variables on the edge.

`/etc/osty/observability.yaml` (edge observability config, not policy):

```yaml
minRequestCount: 50
providers:
  - name: prom-prod
    kind: PROMETHEUS
    endpoint: http://prometheus.monitoring.svc:9090
    bearerTokenEnv: PROMETHEUS_TOKEN
    queries:
      requests: 'sum(increase(http_requests_total{$selector}[$window]))'
      errors: 'sum(increase(http_requests_total{$selector,code=~"5.."}[$window]))'
      p99Seconds: 'histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket{$selector}[$window])))'
      oomKills: 'sum(increase(container_oom_events_total{$selector}[$window]))'
  - name: datadog-us1
    kind: DATADOG
    endpoint: https://api.datadoghq.com
    apiKeyEnv: DD_API_KEY
    appKeyEnv: DD_APP_KEY
workloads:
  "k8s:prod-eu1:payments:Deployment/checkout":
    provider: prom-prod
    workload: checkout
    labels:
      namespace: payments
  "k8s:prod-eu1:shop:Deployment/api":
    provider: datadog-us1
    workload: api
    labels:
      env: prod
```

Table: Observability config fields

| Field | Meaning |
| --- | --- |
| `minRequestCount` | Canary requests required before error-rate and p99 deltas are judged. Defaults to 50 when omitted or zero. |
| `providers[].kind` | `PROMETHEUS` or `DATADOG`. `CLOUDWATCH` is also accepted, with `region` and AWS credential variable names. |
| `providers[].endpoint` | Prometheus base URL, or the Datadog API site such as `https://api.datadoghq.com`. |
| `providers[].queries` | Optional overrides for `requests`, `errors`, `p99Seconds` and `oomKills`. Omitted keys use the defaults below. |
| `workloads.<key>` | An Osty workload key such as `k8s:<cluster>:<namespace>:<Kind>/<name>`, bound to a `provider`, a `workload` name and optional `labels`. |

## How does Osty build each query?

For Prometheus, `$selector` becomes `workload="<workload>"` plus each label as `key="value"`, and `$window` becomes the window length in seconds, such as `900s`. Each signal is an instant query against `/api/v1/query` at the end of the window, summed across returned series, with NaN and infinite samples skipped.

For Datadog, `$selector` becomes `service:<workload>` plus each label as `key:value`. Osty queries `/api/v1/query` over the window with the `DD-API-KEY` and `DD-APPLICATION-KEY` headers, sums the request, error and OOM-kill points, and takes the maximum p99 point.

Table: Default queries when `queries` is omitted

| Signal | Prometheus default | Datadog default |
| --- | --- | --- |
| `requests` | `sum(increase(http_requests_total{$selector}[$window]))` | `sum:trace.http.request.hits{$selector}.as_count()` |
| `errors` | `sum(increase(http_requests_total{$selector,code=~"5.."}[$window]))` | `sum:trace.http.request.errors{$selector}.as_count()` |
| `p99Seconds` | `histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket{$selector}[$window])))` | `p99:trace.http.request.duration{$selector}` |
| `oomKills` | `sum(increase(container_oom_events_total{$selector}[$window]))` | `sum:kubernetes.containers.oom_events{$selector}.as_count()` |

## How do I point osty-edge at the config?

Set `observabilityConfig` in the edge runtime config to the file path, and export the variables the providers name, such as `PROMETHEUS_TOKEN`, `DD_API_KEY` and `DD_APP_KEY`, in the edge's environment.

`observabilityConfig` in `/etc/osty/edge-runtime.yaml` (edge runtime config, not policy):

```yaml
orgId: 7f9c0c56-7a8e-4f4b-9d55-1f9f1d1c2e3a
observabilityConfig: /etc/osty/observability.yaml
```

Run the edge with policy and runtime config:

```bash
osty-edge serve \
  --edge-id edge-prod-eu1 \
  --control-url https://control.osty.example.com \
  --tls-ca /etc/osty/tls/ca.crt --tls-cert /etc/osty/tls/tls.crt --tls-key /etc/osty/tls/tls.key \
  --policy .osty/policy.yaml \
  --runtime-config /etc/osty/edge-runtime.yaml \
  --cache-path /var/lib/osty/edge-cache.sqlite
```

With the `osty-edge` Helm chart, set `edge.runtimeConfig.observabilityConfig` to a path you mount through `edge.extraVolumes` and `edge.extraVolumeMounts`, and pass the provider secrets through `edge.env` or `edge.envFrom`.

## Which policy fields pair with the provider config?

Thresholds live in `.osty/policy.yaml`; the provider config only says where to read metrics. `canaryDefaults` applies to every tier, and a tier can tighten it with `canarySoakMinutes`, `canaryMaxErrorRateDeltaPct`, `canaryMaxP99DeltaPct` and `canaryZeroOOMKills`. A tier that permits automated rollout must keep `requireObservabilityGate: true`.

`autonomy` section of `.osty/policy.yaml`:

```yaml
autonomy:
  defaultTier: VERIFIED_PR
  canaryDefaults:
    soakMinutes: 30
    maxErrorRateDeltaPct: 1.0
    maxP99DeltaPct: 20
    zeroOOMKills: true
  tiers:
    TIER_0:
      maxAutonomy: VERIFIED_PR
      requireObservabilityGate: true
    TIER_1:
      maxAutonomy: AUTO_MERGE_SAFE
      allowStaleMainAutoRedeploy: true
      requireObservabilityGate: true
      canarySoakMinutes: 15
      canaryMaxErrorRateDeltaPct: 0.5
      canaryMaxP99DeltaPct: 15
      canaryZeroOOMKills: true
    TIER_2:
      maxAutonomy: CANARY_ROLLOUT
      allowStaleMainAutoRedeploy: true
      requireObservabilityGate: true
```

The baseline window is the soak length, at least 15 minutes and at most 60, ending at the deploy. A 15-minute Tier-1 soak compares against the 15 minutes before the deploy, and the 30-minute default compares against the 30 minutes before it. When a workload in a wave has no provider bound, `CANARY_ROLLOUT` and stale-main redeploys fall back to `VERIFIED_PR` at run time.

## What happens when a canary fails?

A `ROLLBACK` outcome redeploys the workload's previous digest and halts the wave until an operator approves it. The `killSwitch` section decides what happens when the cause is a compromised package: `osty-proxy` freezes a `CONFIRMED_MALICIOUS` artifact, stateless workloads roll back to their last attested digest, and a workload that ran a schema migration is contained and rebuilt forward instead of rolled back blindly. Broad rollbacks need two operators.

`killSwitch` section of `.osty/policy.yaml`:

```yaml
killSwitch:
  autoFreezeProxyOnConfirmedMalicious: true
  autoRollbackStatelessWorkloads: true
  statefulMigrationAction: CONTAIN_AND_FORWARD_REBUILD
  requireDualControlForBroadRollback: true
```

Adversarial scenario `a12` tests this path: one compromised package hits a stateless service and a service that ran `migrations/0042_add_ledger.sql`, and only the stateless one may roll back.

## Frequently asked questions

### Why does Osty wait for 50 requests?

On a quiet service, one timeout out of two requests is a 50% error rate. The floor stops rate and latency deltas from deciding a rollout until the sample means something. OOM kills are checked from the first request.

### Does Osty support CloudWatch?

Yes. Set `kind: CLOUDWATCH` with `region`, optional `periodSeconds` and the names of the AWS credential variables.

### Can a repository lower the traffic floor?

No. `minRequestCount` lives in the edge observability config, which repository policy overlays cannot change.

## Related pages

- [Ship](https://osty.dev/ship): Fleet campaigns on Temporal, offline AI migrations capped at `VERIFIED_PR`, the Policy Patch Verifier, CI side-effect classification, canary gates and a stateful-safe kill switch.
- [Kubernetes integration](https://osty.dev/integrations/kubernetes): Deploy the `osty-edge` Helm chart that runs the canary gate.
- [Policy builder](https://osty.dev/tools/policy-builder): Generate and validate a `.osty/policy.yaml` with canary floors, autonomy caps and kill-switch rules.
- [Benchmarks](https://osty.dev/benchmarks): The 15-scenario adversarial benchmark, including the stateful-safe kill switch `a12`.

## See your fleet in 10 minutes

Connect a read-only GitHub App and cloud role. Osty installs nothing in your environment and writes nothing to your repositories, and the report shows false positives, stale deploys and unowned workloads.

Get a free X-Ray: https://osty.dev/xray

Written by Osty Engineering. Published 2026-11-29. Updated 2026-11-29.

Canonical: https://osty.dev/integrations/prometheus-datadog
