Skip to content

HTTP(S) with content check (http_content) ​

Requests a page, follows a bounded number of redirects, and checks the final status against the set you expect and the body against text or regular expressions it must or must not contain. Over HTTPS it also reports how long the device's certificate remains valid. It sits beside http_status, which only looks at the status and is cheaper.

What it looks like ​

The page of a http_content sensor in the light theme

The sensor's page after a few polls, watching a web target the test run starts on this machine. In the dark theme: the sensor's page. The form for adding it, with its parameters filled in: light, dark.

Channels ​

KeyNameUnitDefault limits
status_codeStatus codenonenone
response_msResponse timemswarning above 2000, error above 10000
body_bytesBody sizeBnone
content_matchContent checknoneDown when 0. Only reported when a content check is set.
cert_days_remainingDays until the certificate expiresdayswarning below 21, error below 7; only over HTTPS
chain_days_remainingDays until the earliest expiry in the chaindayswarning below 21, error below 7; only over HTTPS

response_ms adds up the time of every request in a redirect chain. body_bytes is the size the server sent, even when only the first part was searched. The certificate channels work as for http_status; see certificate expiry. They come from the first request, the one aimed at the device, and are absent over plain HTTP or with check_certificate off.

Parameters ​

ParameterDefaultMeaning
schemehttpshttp or https.
port80 or 443TCP port.
path/Path and query, starting with /, without spaces or control characters.
methodGETGET, HEAD or POST. A content check needs a body, so it cannot be combined with HEAD.
json_bodynoneSent as the body of a POST, with Content-Type: application/json. Valid JSON, at most 64 KiB.
headersnoneExtra request headers as {"name": ..., "value": ...}, at most 16. Not for credentials, see below.
authnoneHow the secret credential is sent: {"type": "bearer"}, {"type": "basic"} (the secret is user:password) or {"type": "header", "name": "X-Token", "prefix": "Key "}.
expected_status["200-299"]Codes that count as healthy: 204, 2xx or 200-299.
max_redirects50 to 10.
verify_tlstrueCheck the server certificate.
tls_fingerprintnoneTrust exactly the certificate with this SHA-256 fingerprint (colon-separated or plain hex, either case) and no other (on a redirect to another host the pin is not used there), whatever its chain, dates or name say; verify_tls is then not needed. See pinning a certificate.
must_containnoneThe body must contain this text.
must_not_containnoneThe body must not contain this text.
must_matchnoneThe body must match this regular expression (Rust syntax; no look-around or back-references).
must_not_matchnoneThe body must not match this regular expression.
max_body_bytes1048576How much of the body is read and searched, 1 to 10485760. When the body is longer, the message says only the first part was searched.
check_certificatetrueWith https, also report cert_days_remaining and chain_days_remaining. Turn it off when a tls_cert sensor already watches the same certificate. Ignored with http.

Suggested interval: 60 seconds. Credential: a secret, only when auth is set.

Secrets never travel in parameters ​

Parameters are stored and shown in clear. The sensor therefore refuses a header in headers that looks like a credential (Authorization, Cookie, X-Api-Key, anything with token, secret or password in its name) and says to use auth. Create a credential of kind secret in the vault and assign it to the sensor, its device or a group above it. The value is sent in the request, never written to a message, a log or a payload. When a redirect leads to another host, the secret is not sent there.

On the target ​

A web server reachable from the probe host. For HTTPS with verify_tls on, a certificate that the probe host trusts and that matches the device's host name.

Failures ​

MessageMeaning
HTTP N is not in the expected set [...]Down. A successful poll with an unexpected status.
the body does not contain "...", the body contains "...", which it must not, the body does not match /.../, the body matches /.../, which it must notDown. The content check failed.
cannot connect: ... (kind unreachable), no final response within N ms (kind timeout), TLS error: ... (kind protocol)As for http_status.
this sensor needs a secret credential ... (kind config)auth is set and no secret is assigned or inherited.
certificate for ... expired N days ago and the other certificate messagesAs for http_status: Down, with verify_tls off or a pin.

Verification ​

AGPL-3.0-only