blob: a3e7fe532f4480da202701eec6ae3c91913061c3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
dbrp "telegraf"."autogen"
var message = '''
{{- if eq .Level "OK" -}}
certificate for {{ index .Tags "site" }} has been renewed
{{- else -}}
certificate for {{ index .Tags "site" }} is about to expire
{{- end -}}
'''
var details = '''
{{- if eq .Level "OK" -}}
certificate for {{ index .Tags "site" }} now expires in {{ index .Fields "days_remaining" }} days
{{- else -}}
certificate for {{ index .Tags "site" }} has only {{ index .Fields "days_remaining" }} days remaining
{{- end -}}
'''
stream
|from()
.measurement('certbot')
.groupBy('site')
|max('days_remaining')
.as('days_remaining')
|alert()
.crit(lambda: "days_remaining" < 7)
.message(message)
.details(details)
|