Skip to main content

Postgres

This check will try to connect 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:
interval: 30
postgres:
- 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
FieldDescriptionSchemeRequired
queryquery that needs to be executed on the serverstringYes
resultsNumber rows to check forintYes
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://postgres/instance Mutually exclusive with username, password
Connection
urlIf the url is specifed in both the connection and in the url field, the url field takes precedence
username Mutually exclusive with connection EnvVar
password Mutually exclusive with connection EnvVar

Result Variables

NameDescriptionScheme
rows[]map[string]interface{ }
countNumber of rows returnedint