SQL
This check connects to a specified Postgres database, run a query against it and verify the results.
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: postgres-check
spec:
schedule: '@every 30s'
postgres: # or mysql, mssql
- name: postgres schemas check
url: "postgres://$(username):$(password)@postgres.default.svc:5432/postgres?sslmode=disable"
username:
valueFrom:
secretKeyRef:
name: postgres-credentials
key: USERNAME
password:
valueFrom:
secretKeyRef:
name: postgres-credentials
key: PASSWORD
query: SELECT current_schemas(true)
display:
template: |
{{- range $r := .results.rows }}
{{- $r.current_schemas}}
{{- end}}
results: 1
Field | Description | Scheme |
---|---|---|
name* | Name of the check, must be unique within the canary |
|
query* | Query to execute against the Postgres database | SQL |
results | Number of expected rows in results |
|
description | Description for the check |
|
display | Expression to change the formatting of the display | |
icon | Icon for overwriting default icon on the dashboard | |
labels | Labels for check | map[string]string |
metrics | Metrics to export from | |
test | Evaluate whether a check is healthy | |
transform | Transform data from a check into multiple individual checks | |
connection | The connection url to use, mutually exclusive with | |
url | If |
|
username | ||
password |
Result Variables
Name | Description | Scheme |
---|---|---|
rows | []map[string]interface | |
count | Number of rows returned | int |
SQL Server
# ...
kind: Canary
spec:
mssql:
- url: "server=mssql.default.svc;user id=$(username);password=$(password);port=1433;database=master"
# ...
MySQL
# ...
kind: Canary
spec:
mysql:
- url: "$(username):$(password)@tcp(mysql.default.svc:3306)/mysqldb"
# ...
Postgres
# ...
kind: Canary
spec:
mysql:
- url: "postgres://$(username):$(password)@postgres.default.svc:5432/postgres?sslmode=disable"
# ...