Skip to content

Commit a4ae533

Browse files
committed
changes
1 parent 7207449 commit a4ae533

14 files changed

+222
-11
lines changed
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);

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+
interval: 30
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/minimal/_setup.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

fixtures/minimal/containerd-pull.yaml

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: containerd-pull-check
5+
spec:
6+
interval: 30
7+
containerd: # use docker if running outside kubernetes / docker
8+
- name: pull image
9+
image: docker.io/library/busybox:1.31.1
10+
expectedDigest: sha256:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209
11+
expectedSize: 764556

fixtures/minimal/containerd-push.yaml

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: containerd-push-check
5+
spec:
6+
interval: 30
7+
containerdPush: # use dockerPush if running outside kubernetes / docker
8+
- name: ContainerdPush Check
9+
image: docker.io/library/busybox:1.31.1
10+
username: <insert-username>
11+
password: <insert-password>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: canaries.flanksource.com/v1
3+
kind: Canary
4+
metadata:
5+
name: currency-converter-display-cel
6+
spec:
7+
http:
8+
- name: USD
9+
url: https://api.frankfurter.app/latest?from=USD&to=GBP,EUR,ILS,ZAR
10+
display:
11+
expr: "'$1 = €' + string(json.rates.EUR) + ', £' + string(json.rates.GBP) + ', ₪' + string(json.rates.ILS)"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: canaries.flanksource.com/v1
3+
kind: Canary
4+
metadata:
5+
name: currency-converter-display-gotemplate
6+
spec:
7+
http:
8+
- name: USD
9+
url: https://api.frankfurter.app/latest?from=USD&to=GBP,EUR,ILS,ZAR
10+
display:
11+
template: "$1 = €{{.json.rates.EUR}}, £{{.json.rates.GBP}}, ₪{{.json.rates.ILS}}"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: canaries.flanksource.com/v1
2+
kind: Canary
3+
metadata:
4+
name: currency-converter-display-js
5+
spec:
6+
http:
7+
- name: USD
8+
url: https://api.frankfurter.app/latest?from=USD&to=GBP,EUR,ILS
9+
display:
10+
javascript: |
11+
currencyCodes = { "EUR": "€", "GBP": "£", "ILS": "₪"}
12+
13+
display = []
14+
for (var currency in json.rates) {
15+
display.push(currency + " = " + currencyCodes[currency] + json.rates[currency])
16+
}
17+
18+
// final output to display
19+
"$1 = " + display.join(", ")

0 commit comments

Comments
 (0)