Prometheus

How a release wave's checks read Prometheus, what a check does when Prometheus is down, and how to point Wardn at it.

A release can verify each wave before the next one starts. A wave's check is a Prometheus query that reduces to one number and a threshold: "the error rate stays below 1%". Wardn runs the query when the wave has been applied and compares the number with the threshold.

A check can read Datadog instead, by starting its query with datadog: (a monitor's state, or a metric query). Everything below is about Prometheus.

What a check reads

Prometheus answersThe check reads
One numberPass if it is on the right side of the threshold, Fail if not. Zero is a number.
No series for the queryUnknown. No data is not zero.
NaN or an infinityUnknown. A threshold cannot judge it.
Several seriesUnknown, with the message that the query must be reduced to one number (sum, avg, max). Wardn does not choose one for you.
An error, a timeout, a redirect, a refused token or more than 1 MiBUnknown.

An unknown check is never a pass. The wave pauses and says why, and a person resumes it, skips the check or cancels the release.

What happens when Prometheus is down

Each query waits at most WARDN_PROMETHEUS_TIMEOUT (5 seconds by default, at most 30). Five failures in a row open a circuit breaker: for the next 30 seconds every check reads unknown at once, without a request, so a Prometheus that is down does not hold up every release for the length of a timeout. One trial query goes through when the 30 seconds are over, and a good answer closes the breaker. At most 16 queries are in flight; the rest read unknown.

The Integrations page shows what the breaker sees. Wardn also asks Prometheus a constant question every ten seconds, so a Prometheus that stops reads Down within about a minute, with how long it has been down and when Wardn tries again, even when no release is running. See Integration health.

You can also pause Prometheus there. A paused Prometheus is treated exactly like a down one: every check reads unknown without a request, and the waves that have checks pause. Resume it and the checks read again.

Connect it

The person who runs Wardn sets these on the server; see Configuration.

VariableMeaning
WARDN_PROMETHEUS_URLPrometheus's address. Unset, every check reads unknown.
WARDN_PROMETHEUS_TOKEN or WARDN_PROMETHEUS_TOKEN_FILEA bearer token, if Prometheus asks for one.
WARDN_PROMETHEUS_CA_FILEExtra root certificates, for a private CA.
WARDN_PROMETHEUS_TIMEOUTHow long one query may take.

The address must be https:// and cannot carry a user name or password. Wardn sends the query as a POST to /api/v1/query and never follows a redirect.

Writing a check

Reduce the query to one number yourself:

sum(rate(http_requests_total{app="payments-api",code=~"5.."}[5m]))
  / sum(rate(http_requests_total{app="payments-api"}[5m]))

A constant needs no wrapper: Wardn reads a scalar result as well as a vector of one.

On this page