convert prometheus ssl expiry time from epoch unix time to human readable in alerts

1,794 views
Skip to first unread message

Jyotir Bhandari

unread,
Nov 30, 2017, 11:49:40 PM11/30/17
to Prometheus Users
Hi,

I have integrated alerts with slack and I want ssl expiry to show date/time in human readable format.

Currently the value with I am getting in slack is something like 5.023386e+06

My configuration alerts look like this.

alerts :

- alert: SSLExpiry
    expr: probe_ssl_earliest_cert_expiry{job="blackbox"} - time() < 86400 * 60
    for: 5m
    labels:
      severity: critical
      value: '{{ $value }}'
    annotations:
      description: '{{ $labels.instance }} of job {{ $labels.job }} is SSL EXPIRING
        SOON'
      summary: Instance {{ $labels.instance }}, SSL Expiring Soon

Regards,
Jyotir

Ben Kochie

unread,
Dec 1, 2017, 2:10:41 AM12/1/17
to Jyotir Bhandari, Prometheus Users
What your're looking for is {{ $value | humanizeDuration }}

Take a look at our version of this: https://gitlab.com/gitlab-com/runbooks/blob/master/alerts/ssl-certificate-expiration.rules

The reference doc is a little obscure, but it can be found here:


--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/34fb2e34-8a5a-43ff-9102-6c75b17a93ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jyotir Bhandari

unread,
Dec 1, 2017, 2:39:40 AM12/1/17
to Prometheus Users
Thanks that was what I was looking for.

For reference: 

 - alert: SSLExpiry
    expr: probe_ssl_earliest_cert_expiry{job="blackbox"} - time() < 86400 * 60
    for: 5m
    labels:
      severity: critical
      value: '{{ $value | humanizeDuration }}'
    annotations:
      description: '{{ $labels.instance }} of job {{ $labels.job }} is SSL EXPIRING
        SOON'
      summary: Instance {{ $labels.instance }}, SSL Expiring Soon

Jyotir
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages