From 1105fccc2d67db220e104a492bbc34aeffd93702 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Mon, 8 Dec 2025 09:51:30 +0100 Subject: [PATCH] ssl: add graphs to dashboard and show logs --- modules/blocks/monitoring/dashboards/SSL.json | 604 +++++++++++++++++- 1 file changed, 594 insertions(+), 10 deletions(-) diff --git a/modules/blocks/monitoring/dashboards/SSL.json b/modules/blocks/monitoring/dashboards/SSL.json index 9c82733..acdbbec 100644 --- a/modules/blocks/monitoring/dashboards/SSL.json +++ b/modules/blocks/monitoring/dashboards/SSL.json @@ -37,6 +37,7 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -55,6 +56,7 @@ "type": "linear" }, "showPoints": "auto", + "showValues": false, "spanNulls": false, "stacking": { "group": "A", @@ -65,13 +67,12 @@ } }, "mappings": [], - "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "red", - "value": null + "value": 0 }, { "color": "transparent", @@ -84,8 +85,8 @@ "overrides": [] }, "gridPos": { - "h": 12, - "w": 24, + "h": 8, + "w": 12, "x": 0, "y": 0 }, @@ -102,11 +103,12 @@ "sortDesc": false }, "tooltip": { + "hideZeros": false, "mode": "single", "sort": "none" } }, - "pluginVersion": "11.4.0", + "pluginVersion": "12.2.0", "targets": [ { "datasource": { @@ -114,7 +116,7 @@ "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" }, "editorMode": "code", - "expr": "ssl_certificate_expiry_seconds", + "expr": "min by(exported_hostname, subject, path) (ssl_certificate_expiry_seconds{subject=~\"CN=$job\"})", "legendFormat": "{{exported_hostname}}: {{subject}} {{path}}", "range": true, "refId": "A" @@ -122,13 +124,596 @@ ], "title": "Certificate Remaining Validity", "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": 0 + } + ] + }, + "unit": "dateTimeFromNow" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 5, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Last *", + "sortDesc": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.2.0", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "systemd_timer_next_trigger_seconds{name=~\"acme-renew-$job.timer\"} * 1000", + "format": "time_series", + "instant": false, + "legendFormat": "{{name}}", + "range": true, + "refId": "A" + } + ], + "title": "Schedule", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "green", + "mode": "fixed" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "footer": { + "reducers": [] + }, + "inspect": false + }, + "decimals": 0, + "mappings": [], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "green", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "% failed" + }, + "properties": [ + { + "id": "unit", + "value": "percentunit" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + }, + { + "id": "max", + "value": 1 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "total" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "color", + "value": { + "mode": "thresholds" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": 0 + }, + { + "color": "transparent", + "value": 1 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byType", + "options": "string" + }, + "properties": [ + { + "id": "custom.minWidth", + "value": 150 + } + ] + }, + { + "matcher": { + "id": "byType", + "options": "number" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 8 + }, + "id": 4, + "options": { + "cellHeight": "sm", + "enablePagination": true, + "frozenColumns": {}, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "12.2.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" + }, + "editorMode": "code", + "exemplar": false, + "expr": "increase(systemd_unit_state{name=~\"acme-(order-renew-)?[[job]].service\", state=\"activating\"}[7d])", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" + }, + "editorMode": "code", + "exemplar": false, + "expr": "increase(systemd_unit_state{name=~\"acme-(order-renew-)?[[job]].service\", state=\"failed\"}[7d])", + "hide": false, + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "B" + } + ], + "title": "Jobs in the Past Week", + "transformations": [ + { + "id": "labelsToFields", + "options": { + "mode": "columns" + } + }, + { + "id": "merge", + "options": {} + }, + { + "id": "groupingToMatrix", + "options": { + "columnField": "state", + "rowField": "name", + "valueField": "Value" + } + }, + { + "id": "calculateField", + "options": { + "alias": "total", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "activating" + } + }, + "operator": "+", + "right": { + "matcher": { + "id": "byName", + "options": "failed" + } + } + }, + "mode": "binary", + "reduce": { + "include": [ + "activating", + "failed" + ], + "reducer": "sum" + } + } + }, + { + "id": "calculateField", + "options": { + "alias": "% failed", + "binary": { + "left": { + "matcher": { + "id": "byName", + "options": "failed" + } + }, + "operator": "/", + "right": { + "matcher": { + "id": "byName", + "options": "total" + } + } + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "desc": true, + "field": "total" + } + ] + } + }, + { + "id": "sortBy", + "options": { + "fields": {}, + "sort": [ + { + "desc": true, + "field": "failed" + } + ] + } + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "includeByName": {}, + "indexByName": {}, + "renameByName": { + "activating": "success", + "name\\state": "Job" + } + } + } + ], + "type": "table" + }, + { + "description": "", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 12, + "x": 12, + "y": 8 + }, + "id": 7, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "If the log panel is empty, it may be because the amount of lines is too high. Try filtering a few jobs first.", + "mode": "markdown" + }, + "pluginVersion": "12.2.0", + "title": "", + "type": "text" + }, + { + "datasource": { + "default": false, + "type": "loki", + "uid": "cd6cc53e-840c-484d-85f7-96fede324006" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 14, + "w": 12, + "x": 12, + "y": 10 + }, + "id": 8, + "options": { + "dedupStrategy": "none", + "enableInfiniteScrolling": false, + "enableLogDetails": false, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": true, + "showTime": true, + "sortOrder": "Descending", + "wrapLogMessage": true + }, + "pluginVersion": "12.2.0", + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "cd6cc53e-840c-484d-85f7-96fede324006" + }, + "direction": "backward", + "editorMode": "code", + "expr": "{unit=~\"acme-(order-renew-)?($job).service\"}", + "queryType": "range", + "refId": "A" + } + ], + "title": "Logs - $job", + "type": "logs" + }, + { + "datasource": { + "type": "prometheus", + "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" + }, + "description": "The job duration is not accurate. Jobs taking less than 15s to run will sometimes appear as taking 100s.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "custom": { + "axisPlacement": "auto", + "fillOpacity": 70, + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineWidth": 0, + "spanNulls": false + }, + "mappings": [ + { + "options": { + "1": { + "color": "green", + "index": 0, + "text": "Running" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "#EAB839", + "value": 0 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 16 + }, + "id": 6, + "options": { + "alignValue": "left", + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "mergeValues": true, + "rowHeight": 0.9, + "showValue": "never", + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.2.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "df80f9f5-97d7-4112-91d8-72f523a02b09" + }, + "editorMode": "code", + "exemplar": false, + "expr": "max(label_replace(systemd_unit_state{name=~\"acme-(order-renew-)?$job.service\", state=\"activating\"}, \"name\", \"$1\", \"name\", \"acme-order-renew-(.*).service\") > 0 or on(name) label_replace(clamp(systemd_timer_last_trigger_seconds{name=~\"acme-renew-$job.timer\"} - (systemd_timer_last_trigger_seconds{name=~\"acme-renew-$job.timer\"} offset 100s) > 0, 0, 1), \"name\", \"$1\", \"name\", \"acme-renew-(.*).timer\")) by (name)", + "format": "time_series", + "hide": false, + "instant": false, + "key": "Q-e1d5c07a-8dcc-4f34-aa5c-cdebcbdda322-0", + "legendFormat": "{{name}}", + "range": true, + "refId": "A" + } + ], + "title": "Job Runs", + "type": "state-timeline" } ], "preload": false, - "schemaVersion": 40, + "schemaVersion": 42, "tags": [], "templating": { - "list": [] + "list": [ + { + "current": { + "text": [ + "All" + ], + "value": [ + "$__all" + ] + }, + "definition": "label_values(systemd_unit_state{name=~\"acme-renew-.*.timer\"},name)", + "includeAll": true, + "label": "Job", + "multi": true, + "name": "job", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(systemd_unit_state{name=~\"acme-renew-.*.timer\"},name)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "/acme-renew-(?.*).timer/", + "type": "query" + } + ] }, "time": { "from": "now-6h", @@ -138,6 +723,5 @@ "timezone": "browser", "title": "SSL Certificates", "uid": "ae818js0bvw8wb", - "version": 8, - "weekStart": "" + "version": 25 }