Skip to content

Commit 7279dae

Browse files
authored
chore: fixtures for docs (#2191)
* chore: update fixtures * changes * chore: replace `endpoint` with `url`
1 parent cd3d9d8 commit 7279dae

34 files changed

+359
-35
lines changed

fixtures/aws/s3_bucket_pass.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ spec:
88
schedule: "@every 5m"
99
folder:
1010
# Check for any backup not older than 7 days and min size 25 bytes
11-
- path: s3://flanksource-public
11+
- name: folder check
12+
path: s3://flanksource-public
1213
awsConnection:
1314
region: eu-central-1
1415
minSize: 50M

fixtures/datasources/GCP/database_backup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ spec:
77
databaseBackup:
88
- name: backup
99
maxAge: 6h
10-
GCP:
10+
gcp:
1111
project: google-project-name
1212
instance: cloudsql-instance-name
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: database-backup-example
5+
spec:
6+
schedule: "@every 5m"
7+
databaseBackup:
8+
- name: backup
9+
maxAge: 6h
10+
gcp:
11+
project: google-project-name
12+
instance: cloudsql-instance-name
13+
gcpConnection:
14+
credentials:
15+
valueFrom:
16+
secretKeyRef:
17+
name: gcp-credentials
18+
key: AUTH_ACCESS_TOKEN
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: database-backup-example
5+
spec:
6+
schedule: "@every 5m"
7+
databaseBackup:
8+
- name: backup
9+
maxAge: 6h
10+
gcp:
11+
project: google-project-name
12+
instance: cloudsql-instance-name
13+
gcpConnection:
14+
connection: connection://gcp/internal
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: alertmanager-check
5+
spec:
6+
schedule: "@every 5m"
7+
alertmanager:
8+
- url: alertmanager.example.com
9+
name: alert-manager-transform
10+
alerts:
11+
- .*
12+
ignore:
13+
- KubeScheduler.*
14+
transform:
15+
javascript: |
16+
var out = _.map(results, function(r) {
17+
return {
18+
name: r.name,
19+
labels: r.labels,
20+
icon: 'alert',
21+
message: r.message,
22+
description: r.message,
23+
}
24+
})
25+
JSON.stringify(out);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: folder-check
5+
spec:
6+
schedule: "@every 5m"
7+
folder:
8+
- path: /etc/
9+
name: folder-check-min
10+
description: Checks if there are at least 10 files in the folder
11+
minCount: 10
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: folder-check
5+
spec:
6+
schedule: "@every 5m"
7+
folder:
8+
- name: pg-backup checks
9+
path: /data/backups
10+
filter:
11+
regex: "pg-backups-.*.zip"
12+
maxAge: 1d # require a daily backup
13+
minSize: 10mb # the backup should be at least 10mb

fixtures/datasources/postgres.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: postgres-check
5+
spec:
6+
schedule: '@every 30s'
7+
postgres: # or mysql, mssql
8+
- name: postgres schemas check
9+
url: "postgres://$(username):$(password)@postgres.default.svc:5432/postgres?sslmode=disable"
10+
username:
11+
valueFrom:
12+
secretKeyRef:
13+
name: postgres-credentials
14+
key: USERNAME
15+
password:
16+
valueFrom:
17+
secretKeyRef:
18+
name: postgres-credentials
19+
key: PASSWORD
20+
query: SELECT current_schemas(true)
21+
display:
22+
template: |
23+
{{- range $r := .results.rows }}
24+
{{- $r.current_schemas}}
25+
{{- end}}
26+
results: 1
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: "container-log-counts"
5+
namespace: observability
6+
# The schedule can be as short or as long as you want, the query will always search for log
7+
# since the last query
8+
schedule: "@every 5m"
9+
http:
10+
- name: container_log_volume
11+
url: "http://elasticsearch.canaries.svc.cluster.local:9200/logstash-*/_search"
12+
headers:
13+
- name: Content-Type
14+
value: application/json
15+
templateBody: true
16+
test:
17+
# if no logs are found, fail the health check
18+
expr: json.?aggregations.logs.doc_count.orValue(0) > 0
19+
# query for log counts by namespace, container and pod that have been created since the last check
20+
body: >-
21+
{
22+
"size": 0,
23+
"aggs": {
24+
"logs": {
25+
"filter": {
26+
"range": {
27+
"@timestamp" : {
28+
{{- if last_result.results.max }}
29+
"gte": "{{ last_result.results.max }}"
30+
{{- else }}
31+
"gte": "now-5m"
32+
{{- end }}
33+
}
34+
}
35+
},
36+
"aggs": {
37+
"age": {
38+
"max": {
39+
"field": "@timestamp"
40+
}
41+
},
42+
"labels": {
43+
"multi_terms": {
44+
"terms": [
45+
{ "field": "kubernetes_namespace_name.keyword"},
46+
{ "field": "kubernetes_container_name.keyword"},
47+
{ "field": "kubernetes_pod_name.keyword"}
48+
],
49+
"size": 1000
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
transform:
57+
# Save the maximum age for usage in subsequent queries and create a metric for each pair
58+
expr: |
59+
json.orValue(null) != null ?
60+
[{
61+
'detail': { 'max': string(json.?aggregations.logs.age.value_as_string.orValue(last_result().?results.max.orValue(time.Now()))) },
62+
'metrics': json.?aggregations.logs.labels.buckets.orValue([]).map(k, {
63+
'name': "namespace_log_count",
64+
'type': "counter",
65+
'value': double(k.doc_count),
66+
'labels': {
67+
"namespace": k.key[0],
68+
"container": k.key[1],
69+
"pod": k.key[2]
70+
}
71+
})
72+
}].toJSON()
73+
: '{}'

fixtures/external/catalog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Canary
33
metadata:
44
name: node-catalogs
55
spec:
6-
interval: 30
6+
schedule: '@every 30s'
77
catalog:
88
- name: ingress-catalog-check
99
selector:

0 commit comments

Comments
 (0)