From 268dd33792a022f64cf92dff97664e5736950755 Mon Sep 17 00:00:00 2001 From: Matthew Macdonald-Wallace Date: Tue, 10 Aug 2021 12:14:13 +0100 Subject: [PATCH] Add TLS Info to Prometheus metric output --- server/prometheus.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/prometheus.js b/server/prometheus.js index 21b83b342..ef3b0352d 100644 --- a/server/prometheus.js +++ b/server/prometheus.js @@ -47,7 +47,26 @@ class Prometheus { update(heartbeat, tlsInfo) { // TODO: TLS Info here - console.log(tlsInfo) + + if (typeof tlsInfo !== "undefined"){ + try { + var is_valid = 0 + if (tlsInfo.valid == true){ + is_valid = 1 + } else { + is_valid = 0 + } + monitor_cert_is_valid.set(this.monitorLabelValues, is_valid) + } catch (e) { + console.error(e) + } + + try { + monitor_cert_days_remaining.set(this.monitorLabelValues, tlsInfo.daysRemaining) + } catch (e) { + console.error(e) + } + } try { monitor_status.set(this.monitorLabelValues, heartbeat.status)