Skip to main content

HTTP

This check performs queries on HTTP endpoints, and HTTP Namespaces to monitor their activity.

http-check.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-check
spec:
interval: 30
http:
- name: http pass response 200 status code
endpoint: https://httpbin.demo.aws.flanksource.com/status/200
thresholdMillis: 3000
responseCodes: [201, 200, 301]
maxSSLExpiry: 7
FieldDescriptionSchemeRequired
urlstringYes
endpointDeprecated, Use url instreadstring
methodHTTP Request method, default to GETstring
headersHeader fields to be used in the query[]EnvVar
bodyRequest Body Contentsstring
templateBodyIf true the body field will be templated using go templates these variables will be availableboo;
responseCodesExpected response codes for the HTTP Request.[]int
responseContentExact response content expected to be returned by the endpoint.string
thresholdMillisMaximum duration in milliseconds for the HTTP request. It will fail the check if it takes longer.int
maxSSLExpiryMaximum number of days until the SSL Certificate expires.int
nameName of the check, must be unique within the canarystringYes
descriptionDescription for the checkstring
iconIcon for overwriting default icon on the dashboardstring
labelsLabels for checkmap[string]string
testEvaluate whether a check is healthyExpression
displayExpression to change the formatting of the displayExpression
transformTransform data from a check into multiple individual checksExpression
metricsMetrics to export from[]Metrics
Connection
connectionPath of existing connection e.g. connection://http/instance
Mutually exclusive with username, password
Connection
username Mutually exclusive with connection EnvVar
password Mutually exclusive with connection EnvVar
urlHTTP URL, if a URL is specified on both the connection and check, the url on the check takes precedence.stringYes
ntlmWhen true will do authentication using NTLM v1 protocolbool
ntlmv2When true will do authentication using NTLM v2 protocolbool

Result Variables

Result variables can be used in test, display and transform expressions

NameDescriptionScheme
codeHTTP response codeint
headersHTTP response headersmap[string]string
elapsedHTTP Request durationtime.Duration
sslAgeTime until SSL certificate expirestime.Duration
contentHTTP Response bodystring
jsonIf Content-Type=application/json response body converted into JSON objectJSON

The above canary (http-check.yaml) is functionally equivalent to http-check-expr.yaml below

http-check-expr.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-check-expr
spec:
interval: 30
http:
- name: http pass response 200 status code
endpoint: https://httpbin.demo.aws.flanksource.com/status/200
test:
expr: "code in [200,201,301] and sslAge > Duration('7d')"

Template Body Variables

NameScheme
metadata.namestring
metadata.metadata.namespacestring
metadata.labelsmap[string]string
{fields from []env}any

Variables defined in env will be available to template with the name that's configured on the spec. Eg: In the following spec, the vars my_secret_path and my_secret_var, defined in env, are available during templating.

http-check.yaml
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-check
spec:
interval: 30
http:
- name: http pass response 200 status code
endpoint: https://example.com/{{.my_secret_path}}
body: |
{
"secret": {{.my_secret_var}}
}
env:
- name: my_secret_var
valueFrom:
secretKeyRef:
name: the-secret
key: key
- name: my_secret_path
value: secret_path

See Escaping variables

Metrics

HTTP Check Metrics
canary_check_http_response_status{status, statusClass, url}CounterResponse code counter for each endpoint
canary_check_http_ssl_expiry{url}Guage

Status class is one of 1xx, 2xx, 3xx, 4xx, 5xx