---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cert-checker-grafana-dashboard
  labels:
    grafana_dashboard: "1"
    app.kubernetes.io/name: cert-checker
    app.kubernetes.io/instance: cert-checker
    app.kubernetes.io/version: "v0.0.6"
data:
  cert-checker.json: |-
    {
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": "Prometheus",
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "limit": 100,
            "name": "Annotations & Alerts",
            "showIn": 0,
            "type": "dashboard"
          }
        ]
      },
      "description": "Dashboard for viewing the status of production certificates. To be used with the cert-checker project.https://github.com/mogensen/cert-checker",
      "editable": true,
      "gnetId": 12833,
      "graphTooltip": 0,
      "links": [],
      "panels": [
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 1
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 0,
            "y": 0
          },
          "id": 4,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid == 0)",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Broken Certificates",
          "type": "stat"
        },
        {
          "datasource": null,
          "description": "Certificates with a lifetime < 30 days",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "noValue": "0",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 3,
            "y": 0
          },
          "id": 9,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "last"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count( ((cert_checker_expire_time{} - time()) / 86400 >= 0) < 30)",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Certificates about to expire",
          "type": "stat"
        },
        {
          "datasource": null,
          "description": "SSLv3 is cryptographically broken and should not be used.\nSSLv3 was deprecated in 1996",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "noValue": "0",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 1
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 6,
            "y": 0
          },
          "id": 12,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid{tls_min_version=\"SSLv3\"})",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Min TLS Version: SSLv3",
          "type": "stat"
        },
        {
          "datasource": null,
          "description": "TLS 1.0 was deprecated in 2020",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "noValue": "0",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "orange",
                    "value": 1
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 9,
            "y": 0
          },
          "id": 13,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid{tls_min_version=\"TLS 1.0\"})",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Min TLS Version: TLS 1.0",
          "type": "stat"
        },
        {
          "datasource": null,
          "description": "TLS 1.1 was deprecated in 2020",
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "noValue": "0",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "orange",
                    "value": 1
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 12,
            "y": 0
          },
          "id": 14,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid{tls_min_version=\"TLS 1.1\"})",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Min TLS Version: TLS 1.1",
          "type": "stat"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "noValue": "0",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 15,
            "y": 0
          },
          "id": 15,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid{tls_min_version=\"TLS 1.2\"})",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Min TLS Version: TLS 1.2",
          "type": "stat"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "noValue": "0",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 18,
            "y": 0
          },
          "id": 16,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid{tls_min_version=\"TLS 1.3\"})",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Min TLS Version: TLS 1.3",
          "type": "stat"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "custom": {},
              "mappings": [],
              "min": 0,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 6,
            "w": 3,
            "x": 21,
            "y": 0
          },
          "id": 5,
          "options": {
            "colorMode": "background",
            "graphMode": "area",
            "justifyMode": "auto",
            "orientation": "auto",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "text": {},
            "textMode": "auto"
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "count(cert_checker_is_valid > 0)",
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Good Certificates",
          "type": "stat"
        },
        {
          "datasource": "Prometheus",
          "description": "",
          "fieldConfig": {
            "defaults": {
              "color": {
                "fixedColor": "red",
                "mode": "fixed"
              },
              "custom": {
                "align": null,
                "displayMode": "color-text",
                "filterable": false
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Is Latest"
                },
                "properties": [
                  {
                    "id": "mappings",
                    "value": [
                      {
                        "from": "",
                        "id": 0,
                        "text": "No",
                        "to": "",
                        "type": 1,
                        "value": "0"
                      },
                      {
                        "from": "1",
                        "id": 1,
                        "text": "Yes",
                        "to": "999999999",
                        "type": 2,
                        "value": "1"
                      }
                    ]
                  },
                  {
                    "id": "custom.align",
                    "value": "left"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "not_after"
                },
                "properties": [
                  {
                    "id": "custom.width",
                    "value": 225
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "not_before"
                },
                "properties": [
                  {
                    "id": "custom.width",
                    "value": 234
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "issuer"
                },
                "properties": [
                  {
                    "id": "custom.width",
                    "value": 395
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "cert_error"
                },
                "properties": [
                  {
                    "id": "custom.width",
                    "value": 640
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 9,
            "w": 24,
            "x": 0,
            "y": 6
          },
          "id": 2,
          "options": {
            "showHeader": true,
            "sortBy": [
              {
                "desc": true,
                "displayName": "not_after"
              }
            ]
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "sum by(dns, issuer, not_before, not_after, cert_error, tls_min_version) (cert_checker_is_valid) == 0",
              "format": "table",
              "instant": true,
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Certificates with errors",
          "transformations": [
            {
              "id": "labelsToFields",
              "options": {}
            },
            {
              "id": "organize",
              "options": {
                "excludeByName": {
                  "Time": true,
                  "Value": true,
                  "container": false
                },
                "indexByName": {
                  "Time": 0,
                  "Value": 7,
                  "cert_error": 5,
                  "dns": 1,
                  "issuer": 2,
                  "not_after": 4,
                  "not_before": 3,
                  "tls_min_version": 6
                },
                "renameByName": {
                  "Value": "Is Valid",
                  "cert_error": "",
                  "current_version": "Current Version",
                  "dns": "",
                  "image": "Image",
                  "latest_version": "Latest Version",
                  "not_after": ""
                }
              }
            }
          ],
          "type": "table"
        },
        {
          "datasource": "Prometheus",
          "description": "",
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "custom": {
                "align": null,
                "displayMode": "color-text",
                "filterable": true
              },
              "decimals": 1,
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "rgb(249, 249, 249)",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 0
                  },
                  {
                    "color": "yellow",
                    "value": 15
                  },
                  {
                    "color": "green",
                    "value": 30
                  }
                ]
              },
              "unit": "d"
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Is Latest"
                },
                "properties": [
                  {
                    "id": "mappings",
                    "value": [
                      {
                        "from": "",
                        "id": 0,
                        "text": "No",
                        "to": "",
                        "type": 1,
                        "value": "0"
                      },
                      {
                        "from": "1",
                        "id": 1,
                        "text": "Yes",
                        "to": "999999999",
                        "type": 2,
                        "value": "1"
                      }
                    ]
                  },
                  {
                    "id": "custom.align",
                    "value": "left"
                  }
                ]
              }
            ]
          },
          "gridPos": {
            "h": 9,
            "w": 24,
            "x": 0,
            "y": 15
          },
          "id": 8,
          "options": {
            "showHeader": true,
            "sortBy": [
              {
                "desc": false,
                "displayName": "Value"
              }
            ]
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "(cert_checker_expire_time{} - time()) / 60/60/24",
              "format": "table",
              "instant": true,
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Certification Expirations",
          "transformations": [
            {
              "id": "labelsToFields",
              "options": {}
            },
            {
              "id": "organize",
              "options": {
                "excludeByName": {
                  "Time": true,
                  "Value": false,
                  "__name__": true,
                  "container": true,
                  "endpoint": true,
                  "instance": true,
                  "job": true,
                  "namespace": true,
                  "pod": true,
                  "service": true
                },
                "indexByName": {
                  "Time": 0,
                  "Value": 7,
                  "cert_error": 5,
                  "dns": 1,
                  "issuer": 2,
                  "not_after": 4,
                  "not_before": 3,
                  "tls_min_version": 6
                },
                "renameByName": {
                  "Value": "",
                  "cert_error": "",
                  "current_version": "Current Version",
                  "dns": "",
                  "image": "Image",
                  "latest_version": "Latest Version",
                  "not_after": ""
                }
              }
            }
          ],
          "type": "table"
        },
        {
          "datasource": null,
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "custom": {
                "align": null,
                "filterable": false
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "green",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 80
                  }
                ]
              }
            },
            "overrides": []
          },
          "gridPos": {
            "h": 8,
            "w": 24,
            "x": 0,
            "y": 24
          },
          "id": 11,
          "options": {
            "showHeader": true
          },
          "pluginVersion": "7.4.3",
          "targets": [
            {
              "expr": "sum by(dns, issuer, not_before, not_after, cert_error, tls_min_version) (cert_checker_is_valid) == 1",
              "format": "table",
              "instant": true,
              "interval": "",
              "legendFormat": "",
              "refId": "A"
            }
          ],
          "title": "Valid Certificates",
          "transformations": [
            {
              "id": "labelsToFields",
              "options": {}
            },
            {
              "id": "filterFieldsByName",
              "options": {
                "include": {
                  "names": [
                    "Time",
                    "dns",
                    "issuer",
                    "not_after",
                    "not_before",
                    "tls_min_version"
                  ]
                }
              }
            }
          ],
          "type": "table"
        }
      ],
      "refresh": "5m",
      "schemaVersion": 27,
      "style": "dark",
      "tags": [],
      "templating": {
        "list": []
      },
      "time": {
        "from": "now-30m",
        "to": "now"
      },
      "timepicker": {
        "refresh_intervals": [
          "10s",
          "30s",
          "1m",
          "5m",
          "15m",
          "30m",
          "1h",
          "2h",
          "1d"
        ]
      },
      "timezone": "",
      "title": "Certificate Checker",
      "uid": "cert-checker",
      "version": 2
    }
