ribbybibby / ssl_exporter

Exports Prometheus metrics for TLS certificates
Apache License 2.0
504 stars 95 forks source link

ssl_exporter dont export timestamp to prometheus #115

Closed petersg closed 1 year ago

petersg commented 1 year ago

Hello all,

I have configured ssl_exporter to check some certs and display it into prometheus -> grafana.

My job config: `- job_name: "ssl" metrics_path: /probe params: module: ["https"] static_configs:

Kind Regards, Petar

britcey commented 1 year ago

The timestamp is the value of the metric - it's not one of the labels. It's a Unix timestamp (seconds since midnight Jan 1, 1970).

ssl_cert_not_after - time()

will give you seconds until expiration

(ssl_cert_not_after - time()) / 86400

will give you days until expiration, etc.

You can use 'humanizeTimestamp' in your alerts to show the actual date of expiration. I include an annotation like:

expiration_time: |
        {{ with printf "ssl_cert_not_after{serial_no='%s'}" .Labels.serial_no |query }}{{ . | first | value | humanizeTimestamp }}{{ end }}
petersg commented 1 year ago

Ok solved, it seems that grafana cant read correctly the $instance and $job but removing this or hardcoded it fix the issue.