Watch an HTTP endpoint
Use a watch-preview binary from the source checkout. This example polls every five seconds, opens an incident after three actual 5xx responses, and recovers after two nonmatching observations. HTTP 4xx responses are nonmatching here; choose a different condition if those should also open an incident.
apiVersion: ding.ing/v1alpha1
kind: Destination
metadata:
id: ops-webhook
spec:
type: webhook
urlRef: {env: OPS_WEBHOOK_URL}
---
apiVersion: ding.ing/v1alpha1
kind: Watch
metadata:
id: api-health
name: API health
spec:
source:
type: http
url: https://api.example.com/health
every: 5s
timeout: 2s
condition:
field: http.status
operator: gte
value: 500
policy:
trigger: transition
consecutive: 3
recoverAfter: 2
onUnknown: hold-incident
destinations:
- ref: ops-webhook
events: [firing, recovered, source_error, source_recovered]
Download the complete manifest. Replace the
example URL with your endpoint. Set OPS_WEBHOOK_URL in the daemon's environment
before starting it, or change the destination to console output for a local trial.
./ding validate examples/watches/api-health.yaml --json
./ding apply examples/watches/api-health.yaml --state-dir ./ding-state --dry-run --json
./ding apply examples/watches/api-health.yaml --state-dir ./ding-state
./ding watch inspect api-health --state-dir ./ding-state --json
Test without a live service
The fixture returns one firing and one recovery. It performs no source I/O or delivery. Its inputs are 500, 502, 503, 200, 200, five seconds apart.
A timeout is unknown input, not an HTTP 5xx observation. A successful 304 advances freshness without counting as a new condition sample. Redirects are rejected. Source semantics explain projection and limits.