summaryrefslogtreecommitdiffstats
path: root/modules/tozt/files
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-07-06 03:34:51 -0400
committerJesse Luehrs <doy@tozt.net>2020-07-06 03:34:51 -0400
commit4e9194920e4dc688accae819e45611b161a5ea14 (patch)
treea99f76d60105dd235c5f74ba3c0d0db60a556fdb /modules/tozt/files
parentab3ea67db930414b23c02f6de47c943834023197 (diff)
downloadpuppet-tozt-4e9194920e4dc688accae819e45611b161a5ea14.tar.gz
puppet-tozt-4e9194920e4dc688accae819e45611b161a5ea14.zip
alert for expiring certificates
Diffstat (limited to 'modules/tozt/files')
-rw-r--r--modules/tozt/files/kapacitor/certbot.tick28
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/tozt/files/kapacitor/certbot.tick b/modules/tozt/files/kapacitor/certbot.tick
new file mode 100644
index 0000000..a3e7fe5
--- /dev/null
+++ b/modules/tozt/files/kapacitor/certbot.tick
@@ -0,0 +1,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)