Grafana dashboard: SSL Monitoring (x509_cert)
Description: A very simple and visual Dashboard to monitor SSL Certificates (x.509) using the native inputs.x509_cert from Telegraf.
It just works automatically once the sources are added to telegraf.

This very simple dashboard helps your Organization to monitor your active SSL Certificates in seconds, with crystal clear view of the status of all of them.

Using the latest version of Telegraf should work, more information [here](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/x509_cert)

![alt tag](https://www.jorgedelacruz.es/wp-content/uploads/2020/02/ssl-grafana-001.png)

{
  "__inputs": [
    {
      "name": "DS_INFLUXDB",
      "label": "InfluxDB",
      "description": "",
      "type": "datasource",
      "pluginId": "influxdb",
      "pluginName": "InfluxDB"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "9.2.0"
    },
    {
      "type": "datasource",
      "id": "influxdb",
      "name": "InfluxDB",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "description": "A very simple and visual Dashboard to monitor SSL Certificates (x.509) using the native inputs.x509_cert from Telegraf.\nIt just works automatically once the sources are added to telegraf.",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "gnetId": 11707,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "influxdb",
        "uid": "${DS_INFLUXDB}"
      },
      "description": "SSL Certificate Monitoring Stat. On the Title of the widget you can find the SSL Certificate name, and on the value the current TTL/Expiry date in days.\n\nThresholds are:\n* From 0 days to 14, Red\n* From 15 days to 30, Orange\n* From 31 days onward, Green",
      "fieldConfig": {
        "defaults": {
          "decimals": 2,
          "mappings": [
            {
              "id": 0,
              "op": "=",
              "text": "N/A",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 0,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "semi-dark-red",
                "value": null
              },
              {
                "color": "semi-dark-orange",
                "value": 14
              },
              {
                "color": "semi-dark-green",
                "value": 30
              }
            ]
          },
          "unit": "d"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 6,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "links": [],
      "maxPerRow": 6,
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "9.2.0",
      "repeat": "ssl_name",
      "repeatDirection": "h",
      "targets": [
        {
          "datasource": {
            "type": "influxdb",
            "uid": "${DS_INFLUXDB}"
          },
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "none"
              ],
              "type": "fill"
            }
          ],
          "measurement": "x509_cert",
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"x509_cert\")\r\n  |> filter(fn: (r) => r[\"san\"]  =~ /${ssl_name:regex}/)\r\n  |> filter(fn: (r) => r[\"_field\"] == \"expiry\")\r\n  |> map(fn: (r) => ({r with _value: r._value / 60 / 60 / 24}))\r\n  |> group(columns: [\"san\"])\r\n  |> last()",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "expiry"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "last"
              },
              {
                "params": [
                  "/60/60/24"
                ],
                "type": "math"
              }
            ]
          ],
          "tags": [
            {
              "key": "source",
              "operator": "=~",
              "value": "/^$ssl_name$/"
            }
          ]
        }
      ],
      "title": "$ssl_name",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "${DS_INFLUXDB}"
      },
      "description": "SSL Certificate Monitoring Table. On the first column you can find the SSL x509 Certificate name, and on the second column the TTL/Expirty Date in days.\n\nThresholds are:\n* From 0 days to 14, Red\n* From 15 days to 30, Orange\n* From 31 days onward, Green",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "filterable": true,
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "days"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Current"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "SSL Expiry in"
              },
              {
                "id": "unit",
                "value": "d"
              },
              {
                "id": "decimals",
                "value": 2
              },
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "custom.align",
                "value": "left"
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "#E02F44",
                      "value": null
                    },
                    {
                      "color": "#FF780A",
                      "value": 14
                    },
                    {
                      "color": "rgba(50, 172, 45, 0.97)",
                      "value": 30
                    }
                  ]
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Days until expiration"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "SSL Certificate"
              },
              {
                "id": "custom.align",
                "value": "right"
              },
              {
                "id": "custom.displayMode",
                "value": "color-background-solid"
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "dark-green",
                      "value": null
                    },
                    {
                      "color": "dark-red",
                      "value": 14
                    },
                    {
                      "color": "semi-dark-orange",
                      "value": 30
                    },
                    {
                      "color": "dark-green",
                      "value": 60
                    }
                  ]
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 10,
        "w": 24,
        "x": 0,
        "y": 7
      },
      "id": 9,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true
      },
      "pluginVersion": "9.2.0",
      "targets": [
        {
          "alias": "$tag_source",
          "datasource": {
            "type": "influxdb",
            "uid": "${DS_INFLUXDB}"
          },
          "groupBy": [
            {
              "params": [
                "$__interval"
              ],
              "type": "time"
            },
            {
              "params": [
                "null"
              ],
              "type": "fill"
            }
          ],
          "orderByTime": "ASC",
          "policy": "default",
          "query": "from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"x509_cert\")\r\n  |> filter(fn: (r) => r[\"san\"]  =~ /${ssl_name:regex}/)\r\n  |> filter(fn: (r) => r[\"_field\"] == \"expiry\")\r\n  |> map(fn: (r) => ({r with _value: r._value / 60 / 60 / 24}))\r\n  |> group(columns: [\"san\"])\r\n  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\r\n  |> yield(name: \"mean\")",
          "rawQuery": true,
          "refId": "A",
          "resultFormat": "time_series",
          "select": [
            [
              {
                "params": [
                  "value"
                ],
                "type": "field"
              },
              {
                "params": [],
                "type": "mean"
              }
            ]
          ],
          "tags": []
        }
      ],
      "transformations": [
        {
          "id": "reduce",
          "options": {
            "labelsToFields": false,
            "reducers": [
              "lastNotNull"
            ]
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {},
            "indexByName": {},
            "renameByName": {
              "Field": "x509 Certificate URL",
              "Last *": "Days until expiration"
            }
          }
        }
      ],
      "transparent": true,
      "type": "table"
    }
  ],
  "schemaVersion": 37,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {},
        "datasource": {
          "type": "influxdb",
          "uid": "${DS_INFLUXDB}"
        },
        "definition": "from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"x509_cert\")\r\n  |> filter(fn: (r) => r[\"san\"] != \"\")\r\n  |> keep(columns: [\"san\"])\r\n  |> distinct(column: \"san\")\r\n  |> group()",
        "hide": 0,
        "includeAll": true,
        "label": "SSL Certificate",
        "multi": true,
        "name": "ssl_name",
        "options": [],
        "query": "from(bucket: v.defaultBucket)\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"x509_cert\")\r\n  |> filter(fn: (r) => r[\"san\"] != \"\")\r\n  |> keep(columns: [\"san\"])\r\n  |> distinct(column: \"san\")\r\n  |> group()",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      }
    ]
  },
  "time": {
    "from": "now-12h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "SSL Monitoring (x509_cert)",
  "uid": "0QnblY8Wz",
  "version": 5,
  "weekStart": ""
}