{
  "title": "WatchCore",
  "uid": "watchcore",
  "description": "Monitors of a WatchCore account, scraped from /api/v1/metrics",
  "tags": ["watchcore"],
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "editable": true,
  "refresh": "1m",
  "time": {"from": "now-24h", "to": "now"},
  "templating": {
    "list": [
      {"name": "datasource", "label": "Prometheus", "type": "datasource", "query": "prometheus", "current": {}, "hide": 0},
      {"name": "project", "label": "Project", "type": "query", "datasource": {"type": "prometheus", "uid": "${datasource}"},
       "query": "label_values(watchcore_monitor_paused, project)",
       "definition": "label_values(watchcore_monitor_paused, project)",
       "refresh": 2, "multi": true, "includeAll": true, "allValue": ".*", "current": {}, "sort": 1, "hide": 0}
    ]
  },
  "panels": [
    {"id": 1, "type": "stat", "title": "Down", "gridPos": {"h": 4, "w": 6, "x": 0, "y": 0},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "count(watchcore_monitor_up{project=~\"$project\"} == 0) or vector(0)"}],
     "fieldConfig": {"defaults": {"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}, {"color": "red", "value": 1}]}}, "overrides": []},
     "options": {"reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}, "colorMode": "background", "graphMode": "none", "textMode": "value"}},
    {"id": 2, "type": "stat", "title": "Open incidents", "gridPos": {"h": 4, "w": 6, "x": 6, "y": 0},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "sum(watchcore_monitor_open_incidents{project=~\"$project\"}) or vector(0)"}],
     "fieldConfig": {"defaults": {"thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}, {"color": "orange", "value": 1}]}}, "overrides": []},
     "options": {"reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}, "colorMode": "background", "graphMode": "none", "textMode": "value"}},
    {"id": 3, "type": "stat", "title": "In maintenance", "gridPos": {"h": 4, "w": 6, "x": 12, "y": 0},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "sum(watchcore_monitor_maintenance{project=~\"$project\"}) or vector(0)"}],
     "fieldConfig": {"defaults": {"thresholds": {"mode": "absolute", "steps": [{"color": "text", "value": null}, {"color": "blue", "value": 1}]}}, "overrides": []},
     "options": {"reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}, "colorMode": "value", "graphMode": "none", "textMode": "value"}},
    {"id": 4, "type": "stat", "title": "Next certificate expiry", "gridPos": {"h": 4, "w": 6, "x": 18, "y": 0},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "min(watchcore_monitor_ssl_expiry_days{project=~\"$project\"})"}],
     "fieldConfig": {"defaults": {"unit": "d", "thresholds": {"mode": "absolute", "steps": [{"color": "red", "value": null}, {"color": "orange", "value": 14}, {"color": "green", "value": 30}]}}, "overrides": []},
     "options": {"reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}, "colorMode": "value", "graphMode": "none", "textMode": "value"}},
    {"id": 5, "type": "state-timeline", "title": "Up or down", "gridPos": {"h": 10, "w": 24, "x": 0, "y": 4},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "watchcore_monitor_up{project=~\"$project\"}", "legendFormat": "{{project}} / {{name}}"}],
     "fieldConfig": {"defaults": {"color": {"mode": "thresholds"},
                                  "thresholds": {"mode": "absolute", "steps": [{"color": "red", "value": null}, {"color": "green", "value": 1}]},
                                  "mappings": [{"type": "value", "options": {"0": {"text": "DOWN", "color": "red", "index": 0}, "1": {"text": "UP", "color": "green", "index": 1}}}]},
                     "overrides": []},
     "options": {"showValue": "never", "mergeValues": true, "rowHeight": 0.8, "legend": {"showLegend": false}}},
    {"id": 6, "type": "timeseries", "title": "Response time", "gridPos": {"h": 9, "w": 16, "x": 0, "y": 14},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "watchcore_monitor_response_time_seconds{project=~\"$project\"}", "legendFormat": "{{project}} / {{name}}"}],
     "fieldConfig": {"defaults": {"unit": "s", "custom": {"lineWidth": 1, "fillOpacity": 0, "spanNulls": false}}, "overrides": []},
     "options": {"legend": {"displayMode": "table", "placement": "right", "calcs": ["mean", "max"]}, "tooltip": {"mode": "multi", "sort": "desc"}}},
    {"id": 7, "type": "bargauge", "title": "Availability in the time range",
     "description": "Share of scrapes with up = 1. The SLA report in WatchCore is the binding figure: it leaves out maintenance and pauses and counts time, not samples.",
     "gridPos": {"h": 9, "w": 8, "x": 16, "y": 14},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "avg_over_time(watchcore_monitor_up{project=~\"$project\"}[$__range]) * 100", "legendFormat": "{{name}}", "instant": true}],
     "fieldConfig": {"defaults": {"unit": "percent", "min": 90, "max": 100, "decimals": 2,
                                  "thresholds": {"mode": "absolute", "steps": [{"color": "red", "value": null}, {"color": "orange", "value": 99}, {"color": "green", "value": 99.9}]}},
                     "overrides": []},
     "options": {"orientation": "horizontal", "displayMode": "basic", "reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}}},
    {"id": 8, "type": "table", "title": "Certificates", "gridPos": {"h": 8, "w": 24, "x": 0, "y": 23},
     "datasource": {"type": "prometheus", "uid": "${datasource}"},
     "targets": [{"refId": "A", "expr": "watchcore_monitor_ssl_expiry_days{project=~\"$project\"}", "format": "table", "instant": true}],
     "transformations": [
       {"id": "organize", "options": {"excludeByName": {"Time": true, "__name__": true, "id": true, "type": true, "job": true, "instance": true},
                                      "renameByName": {"Value": "Days left"}}},
       {"id": "sortBy", "options": {"sort": [{"field": "Days left"}]}}
     ],
     "fieldConfig": {"defaults": {"thresholds": {"mode": "absolute", "steps": [{"color": "red", "value": null}, {"color": "orange", "value": 14}, {"color": "green", "value": 30}]}},
                     "overrides": [{"matcher": {"id": "byName", "options": "Days left"}, "properties": [{"id": "custom.cellOptions", "value": {"type": "color-text"}}]}]},
     "options": {"showHeader": true}}
  ]
}
