{
  "__inputs": [],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "10.4.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "panel",
      "id": "state-timeline",
      "name": "State timeline",
      "version": ""
    },
    {
      "type": "panel",
      "id": "heatmap",
      "name": "Heatmap",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    },
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar gauge",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "uid": "okstatus-uptime-overview",
  "title": "OKStatus · Uptime overview",
  "description": "Every monitor of an OKStatus organization, from its Prometheus export (GET /api/v1/metrics): status, response times per probe region, availability against the SLA target, expirations, private agents. https://okstatus.eu/docs/integrations/prometheus/",
  "tags": [
    "okstatus",
    "uptime",
    "synthetic-monitoring",
    "sla"
  ],
  "editable": true,
  "graphTooltip": 1,
  "refresh": "30s",
  "schemaVersion": 39,
  "version": 1,
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "browser",
  "links": [
    {
      "title": "OKStatus",
      "type": "link",
      "url": "https://okstatus.eu/dashboard",
      "targetBlank": true,
      "icon": "external link"
    },
    {
      "title": "Prometheus export guide",
      "type": "link",
      "url": "https://okstatus.eu/docs/integrations/prometheus/",
      "targetBlank": true,
      "icon": "doc"
    },
    {
      "title": "Source and alerting rules",
      "type": "link",
      "url": "https://github.com/clearcloud-fr/okstatus-grafana",
      "targetBlank": true,
      "icon": "external link"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "templating": {
    "list": [
      {
        "name": "datasource",
        "label": "Data source",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 0,
        "refresh": 1
      },
      {
        "name": "group",
        "label": "Group",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(okstatus_monitor_info, monitor_group)",
          "refId": "group"
        },
        "definition": "label_values(okstatus_monitor_info, monitor_group)",
        "includeAll": true,
        "multi": true,
        "allValue": ".*",
        "current": {},
        "refresh": 2,
        "sort": 1
      },
      {
        "name": "monitor",
        "label": "Monitor",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(okstatus_monitor_info{monitor_group=~\"$group\"}, monitor_name)",
          "refId": "monitor"
        },
        "definition": "label_values(okstatus_monitor_info{monitor_group=~\"$group\"}, monitor_name)",
        "includeAll": true,
        "multi": true,
        "allValue": ".*",
        "current": {},
        "refresh": 2,
        "sort": 1
      },
      {
        "name": "region",
        "label": "Probe region",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(okstatus_region_up, probe_region)",
          "refId": "region"
        },
        "definition": "label_values(okstatus_region_up, probe_region)",
        "includeAll": true,
        "multi": true,
        "allValue": ".*",
        "current": {},
        "refresh": 2,
        "sort": 1
      },
      {
        "name": "window",
        "label": "SLA window",
        "type": "custom",
        "query": "24h,7d,30d",
        "includeAll": false,
        "multi": false,
        "current": {
          "selected": true,
          "text": "30d",
          "value": "30d"
        },
        "options": [
          {
            "selected": false,
            "text": "24h",
            "value": "24h"
          },
          {
            "selected": false,
            "text": "7d",
            "value": "7d"
          },
          {
            "selected": true,
            "text": "30d",
            "value": "30d"
          }
        ]
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "stat",
      "title": "Monitors",
      "description": "Monitors of the organization matching the filters.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 3,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(okstatus_monitor_info{monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "text",
                "value": null
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "center",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Up",
      "description": "Up on the majority of their probe regions.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 3,
        "y": 0,
        "w": 2,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(okstatus_monitor_status{state=\"up\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) or vector(0)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "center",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Degraded",
      "description": "At least one probe region failing, or slow responses, without a majority down.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 5,
        "y": 0,
        "w": 3,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(okstatus_monitor_status{state=\"degraded\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) or vector(0)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#FADE2A",
                "value": 1
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "center",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Down",
      "description": "Down on the majority of their probe regions: the rule OKStatus alerts on.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 8,
        "y": 0,
        "w": 2,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count(okstatus_monitor_up{monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 0) or vector(0)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "center",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 5,
      "type": "gauge",
      "title": "Availability · $window",
      "description": "Mean availability over the window: the same figure as the dashboard, status pages and SLA reports.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 10,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "avg(okstatus_monitor_availability_ratio{window=\"$window\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "decimals": 3,
          "min": 0.99,
          "max": 1,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "#FADE2A",
                "value": 0.995
              },
              {
                "color": "green",
                "value": 0.999
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "showThresholdMarkers": true,
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 6,
      "type": "gauge",
      "title": "Error budget left · $window",
      "description": "Share of the downtime allowed by the organization SLA target that is still unspent over the window.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 14,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "clamp(1 - (1 - avg(okstatus_monitor_availability_ratio{window=\"$window\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"})) / (1 - scalar(okstatus_org_sla_target_ratio)), 0, 1)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "decimals": 0,
          "min": 0,
          "max": 1,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "#FF9830",
                "value": 0.2
              },
              {
                "color": "green",
                "value": 0.5
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "showThresholdMarkers": true,
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 7,
      "type": "stat",
      "title": "Certs < 14 d",
      "description": "TLS certificates expiring within 14 days.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 18,
        "y": 0,
        "w": 3,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count((okstatus_certificate_expiry_timestamp_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\"} - time()) < 14 * 86400) or vector(0)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "#FF9830",
                "value": 1
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "center",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 8,
      "type": "stat",
      "title": "Private agents",
      "description": "Private agents that sent a heartbeat in the last 90 seconds.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 21,
        "y": 0,
        "w": 3,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum(okstatus_private_agent_up) or vector(0)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "none",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "text",
                "value": null
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "center",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 9,
      "type": "state-timeline",
      "title": "Status history",
      "description": "Monitor state over time, under the majority rule.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 4,
        "w": 16,
        "h": 10
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, monitor_name) (\n    (okstatus_monitor_status{state=\"up\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 1\n  or (okstatus_monitor_status{state=\"degraded\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 2\n  or (okstatus_monitor_status{state=\"down\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 3\n  or (okstatus_monitor_status{state=\"maintenance\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 4\n  or (okstatus_monitor_status{state=\"paused\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 5\n  or (okstatus_monitor_status{state=~\"pending|stale\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 6\n)",
          "refId": "A",
          "legendFormat": "{{monitor_name}}",
          "range": true,
          "instant": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "1": {
                  "text": "Up",
                  "color": "green",
                  "index": 0
                },
                "2": {
                  "text": "Degraded",
                  "color": "#FADE2A",
                  "index": 1
                },
                "3": {
                  "text": "Down",
                  "color": "red",
                  "index": 2
                },
                "4": {
                  "text": "Maintenance",
                  "color": "#5794F2",
                  "index": 3
                },
                "5": {
                  "text": "Paused",
                  "color": "#8E8E99",
                  "index": 4
                },
                "6": {
                  "text": "Pending",
                  "color": "#8E8E99",
                  "index": 5
                }
              }
            }
          ],
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#8E8E99",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              },
              {
                "color": "#FADE2A",
                "value": 2
              },
              {
                "color": "red",
                "value": 3
              },
              {
                "color": "#5794F2",
                "value": 4
              },
              {
                "color": "#8E8E99",
                "value": 5
              }
            ]
          },
          "custom": {
            "fillOpacity": 85,
            "lineWidth": 0
          }
        },
        "overrides": []
      },
      "options": {
        "showValue": "never",
        "mergeValues": true,
        "rowHeight": 0.85,
        "alignValue": "left",
        "legend": {
          "showLegend": false
        },
        "tooltip": {
          "mode": "single"
        }
      }
    },
    {
      "id": 10,
      "type": "table",
      "title": "Needs attention",
      "description": "Monitors down or degraded right now, with how many probe regions fail.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 16,
        "y": 4,
        "w": 8,
        "h": 10
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, monitor_name, monitor_group, monitor_type, monitor_host, state) (okstatus_monitor_status{state=~\"down|degraded\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count by (monitor_id) (okstatus_region_up{monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 0)",
          "refId": "B",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto"
          },
          "noValue": "Nothing to report: every monitor is up"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "state"
            },
            "properties": [
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-background"
                }
              },
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "down": {
                        "text": "DOWN",
                        "color": "red"
                      },
                      "degraded": {
                        "text": "DEGRADED",
                        "color": "#FADE2A"
                      }
                    }
                  }
                ]
              }
            ]
          }
        ]
      },
      "options": {
        "showHeader": true,
        "footer": {
          "show": false
        }
      },
      "transformations": [
        {
          "id": "joinByField",
          "options": {
            "byField": "monitor_id",
            "mode": "outer"
          }
        },
        {
          "id": "filterByValue",
          "options": {
            "filters": [
              {
                "fieldName": "state",
                "config": {
                  "id": "isNotNull",
                  "options": {}
                }
              }
            ],
            "type": "include",
            "match": "all"
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Time 1": true,
              "Time 2": true,
              "Value #A": true,
              "__name__": true,
              "monitor_id": true,
              "monitor_type": true,
              "job": true,
              "instance": true
            },
            "indexByName": {
              "monitor_name": 0,
              "state": 1,
              "Value #B": 2,
              "monitor_host": 3,
              "monitor_group": 4
            },
            "renameByName": {
              "monitor_name": "Monitor",
              "state": "State",
              "monitor_host": "Host",
              "monitor_group": "Group",
              "Value #B": "Regions failing"
            }
          }
        }
      ]
    },
    {
      "id": 11,
      "type": "heatmap",
      "title": "Response time · heatmap",
      "description": "Every last-check latency sample, all monitors and regions, bucketed by Grafana.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 14,
        "w": 12,
        "h": 9
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "okstatus_check_latency_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\", probe_region=~\"$region\"}",
          "refId": "A",
          "legendFormat": "__auto",
          "range": true,
          "instant": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "scaleDistribution": {
              "type": "linear"
            }
          }
        },
        "overrides": []
      },
      "options": {
        "calculate": true,
        "calculation": {
          "yBuckets": {
            "mode": "count",
            "value": "30",
            "scale": {
              "type": "log",
              "log": 2
            }
          }
        },
        "color": {
          "mode": "scheme",
          "scheme": "Oranges",
          "steps": 64,
          "exponent": 0.5,
          "fill": "dark-orange"
        },
        "yAxis": {
          "unit": "s",
          "axisPlacement": "left"
        },
        "cellGap": 1,
        "tooltip": {
          "mode": "single",
          "yHistogram": true
        },
        "legend": {
          "show": true
        }
      }
    },
    {
      "id": 12,
      "type": "timeseries",
      "title": "Response time by probe region",
      "description": "Mean of the last check per region (solid) and the hourly p95 rollup (dashed).",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 14,
        "w": 12,
        "h": 9
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "avg by (probe_region) (okstatus_check_latency_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\", probe_region=~\"$region\"})",
          "refId": "A",
          "legendFormat": "{{probe_region}}",
          "range": true,
          "instant": false
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "avg by (probe_region) (okstatus_check_latency_hourly_seconds{percentile=\"p95\", monitor_group=~\"$group\", monitor_name=~\"$monitor\", probe_region=~\"$region\"})",
          "refId": "B",
          "legendFormat": "{{probe_region}} p95 (hour)",
          "range": true,
          "instant": false
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 6,
            "showPoints": "never",
            "spanNulls": true
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "fill": "dash",
                  "dash": [
                    6,
                    4
                  ]
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 1
              },
              {
                "id": "custom.fillOpacity",
                "value": 0
              }
            ]
          }
        ]
      },
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "calcs": [
            "lastNotNull",
            "max"
          ]
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 13,
      "type": "table",
      "title": "Status by probe region",
      "description": "Last check of every monitor from every probe region it runs from.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 23,
        "w": 12,
        "h": 10
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_name, probe_region) (okstatus_region_up{monitor_group=~\"$group\", monitor_name=~\"$monitor\", probe_region=~\"$region\"})",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "center",
            "cellOptions": {
              "type": "color-background"
            }
          },
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          },
          "mappings": [
            {
              "type": "value",
              "options": {
                "1": {
                  "text": "UP",
                  "color": "green"
                },
                "0": {
                  "text": "DOWN",
                  "color": "red"
                }
              }
            },
            {
              "type": "special",
              "options": {
                "match": "null",
                "result": {
                  "text": "·",
                  "color": "transparent"
                }
              }
            }
          ]
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "monitor_name\\probe_region"
            },
            "properties": [
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "auto"
                }
              },
              {
                "id": "custom.align",
                "value": "left"
              },
              {
                "id": "displayName",
                "value": "Monitor"
              }
            ]
          }
        ]
      },
      "options": {
        "showHeader": true
      },
      "transformations": [
        {
          "id": "groupingToMatrix",
          "options": {
            "columnField": "probe_region",
            "rowField": "monitor_name",
            "valueField": "Value",
            "emptyValue": "null"
          }
        }
      ]
    },
    {
      "id": 14,
      "type": "bargauge",
      "title": "Availability vs SLA target · $window",
      "description": "Availability of each monitor over the window. Thresholds: 99.5 % and 99.9 %.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 23,
        "w": 12,
        "h": 10
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "okstatus_monitor_availability_ratio{window=\"$window\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"}",
          "refId": "A",
          "legendFormat": "{{monitor_name}}",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "decimals": 3,
          "min": 0.99,
          "max": 1,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "#FADE2A",
                "value": 0.995
              },
              {
                "color": "green",
                "value": 0.999
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "orientation": "horizontal",
        "displayMode": "basic",
        "showUnfilled": true,
        "valueMode": "color",
        "namePlacement": "left",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 15,
      "type": "table",
      "title": "Monitors",
      "description": "One row per monitor. Click a header to sort.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 33,
        "w": 24,
        "h": 11
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, monitor_name, monitor_group, monitor_type, monitor_host) (okstatus_monitor_info{monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id) (\n    (okstatus_monitor_status{state=\"up\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 1\n  or (okstatus_monitor_status{state=\"degraded\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 2\n  or (okstatus_monitor_status{state=\"down\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 3\n  or (okstatus_monitor_status{state=\"maintenance\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 4\n  or (okstatus_monitor_status{state=\"paused\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 5\n  or (okstatus_monitor_status{state=~\"pending|stale\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} == 1) * 6\n)",
          "refId": "B",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "avg by (monitor_id) (okstatus_check_latency_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "C",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id) (okstatus_monitor_availability_ratio{window=\"24h\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "D",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id) (okstatus_monitor_availability_ratio{window=\"7d\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "E",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id) (okstatus_monitor_availability_ratio{window=\"30d\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"})",
          "refId": "F",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id) ((okstatus_certificate_expiry_timestamp_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\"} - time()) / 86400)",
          "refId": "G",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "State"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "1": {
                        "text": "Up",
                        "color": "green",
                        "index": 0
                      },
                      "2": {
                        "text": "Degraded",
                        "color": "#FADE2A",
                        "index": 1
                      },
                      "3": {
                        "text": "Down",
                        "color": "red",
                        "index": 2
                      },
                      "4": {
                        "text": "Maintenance",
                        "color": "#5794F2",
                        "index": 3
                      },
                      "5": {
                        "text": "Paused",
                        "color": "#8E8E99",
                        "index": 4
                      },
                      "6": {
                        "text": "Pending",
                        "color": "#8E8E99",
                        "index": 5
                      }
                    }
                  }
                ]
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "#8E8E99",
                      "value": null
                    },
                    {
                      "color": "green",
                      "value": 1
                    },
                    {
                      "color": "#FADE2A",
                      "value": 2
                    },
                    {
                      "color": "red",
                      "value": 3
                    },
                    {
                      "color": "#5794F2",
                      "value": 4
                    },
                    {
                      "color": "#8E8E99",
                      "value": 5
                    }
                  ]
                }
              },
              {
                "id": "color",
                "value": {
                  "mode": "thresholds"
                }
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-background"
                }
              },
              {
                "id": "custom.width",
                "value": 120
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Latency"
            },
            "properties": [
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/^Availability/"
            },
            "properties": [
              {
                "id": "unit",
                "value": "percentunit"
              },
              {
                "id": "decimals",
                "value": 3
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "red",
                      "value": null
                    },
                    {
                      "color": "#FADE2A",
                      "value": 0.995
                    },
                    {
                      "color": "green",
                      "value": 0.999
                    }
                  ]
                }
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Certificate"
            },
            "properties": [
              {
                "id": "decimals",
                "value": 0
              },
              {
                "id": "unit",
                "value": "suffix: d"
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "red",
                      "value": null
                    },
                    {
                      "color": "#FF9830",
                      "value": 14
                    },
                    {
                      "color": "text",
                      "value": 30
                    }
                  ]
                }
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              }
            ]
          }
        ]
      },
      "options": {
        "showHeader": true,
        "sortBy": [
          {
            "displayName": "State",
            "desc": true
          }
        ],
        "footer": {
          "show": false
        }
      },
      "transformations": [
        {
          "id": "joinByField",
          "options": {
            "byField": "monitor_id",
            "mode": "outer"
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Time 1": true,
              "Time 2": true,
              "Time 3": true,
              "Time 4": true,
              "Time 5": true,
              "Time 6": true,
              "Time 7": true,
              "Value #A": true,
              "__name__": true,
              "monitor_id": true,
              "regions": true,
              "job": true,
              "instance": true
            },
            "indexByName": {
              "monitor_name": 0,
              "monitor_group": 1,
              "monitor_type": 2,
              "monitor_host": 3,
              "Value #B": 4,
              "Value #C": 5,
              "Value #D": 6,
              "Value #E": 7,
              "Value #F": 8,
              "Value #G": 9
            },
            "renameByName": {
              "monitor_name": "Monitor",
              "monitor_group": "Group",
              "monitor_type": "Type",
              "monitor_host": "Host",
              "Value #B": "State",
              "Value #C": "Latency",
              "Value #D": "Availability 24 h",
              "Value #E": "Availability 7 d",
              "Value #F": "Availability 30 d",
              "Value #G": "Certificate"
            }
          }
        }
      ]
    },
    {
      "id": 16,
      "type": "bargauge",
      "title": "Upcoming expirations",
      "description": "Days left before each TLS certificate and registered domain expires.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 44,
        "w": 12,
        "h": 9
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "(okstatus_certificate_expiry_timestamp_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\"} - time()) / 86400",
          "refId": "A",
          "legendFormat": "certificate · {{monitor_host}}",
          "range": false,
          "instant": true
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "(okstatus_domain_expiry_timestamp_seconds - time()) / 86400",
          "refId": "B",
          "legendFormat": "domain · {{domain}}",
          "range": false,
          "instant": true
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "suffix: d",
          "decimals": 0,
          "min": 0,
          "max": 365,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "#FF9830",
                "value": 14
              },
              {
                "color": "green",
                "value": 30
              }
            ]
          },
          "color": {
            "mode": "thresholds"
          }
        },
        "overrides": []
      },
      "options": {
        "orientation": "horizontal",
        "displayMode": "basic",
        "showUnfilled": true,
        "valueMode": "color",
        "namePlacement": "left",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      }
    },
    {
      "id": 17,
      "type": "table",
      "title": "Private agents",
      "description": "Agents running in your own infrastructure: liveness, version and load.",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 44,
        "w": 12,
        "h": 9
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (agent_id, agent_name, site, version, platform) (okstatus_private_agent_info)",
          "refId": "A",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (agent_id) (okstatus_private_agent_up)",
          "refId": "B",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (agent_id) (time() - okstatus_private_agent_last_heartbeat_timestamp_seconds)",
          "refId": "C",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (agent_id) (okstatus_private_agent_active_checks / okstatus_private_agent_max_concurrent_checks)",
          "refId": "D",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "State"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "1": {
                        "text": "UP",
                        "color": "green"
                      },
                      "0": {
                        "text": "OFFLINE",
                        "color": "red"
                      }
                    }
                  }
                ]
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-background"
                }
              },
              {
                "id": "custom.width",
                "value": 90
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Last heartbeat"
            },
            "properties": [
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Load"
            },
            "properties": [
              {
                "id": "unit",
                "value": "percentunit"
              },
              {
                "id": "min",
                "value": 0
              },
              {
                "id": "max",
                "value": 1
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "gauge",
                  "mode": "basic"
                }
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "green",
                      "value": null
                    },
                    {
                      "color": "#FF9830",
                      "value": 0.7
                    },
                    {
                      "color": "red",
                      "value": 0.9
                    }
                  ]
                }
              }
            ]
          }
        ]
      },
      "options": {
        "showHeader": true
      },
      "transformations": [
        {
          "id": "joinByField",
          "options": {
            "byField": "agent_id",
            "mode": "outer"
          }
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Time 1": true,
              "Time 2": true,
              "Time 3": true,
              "Time 4": true,
              "Value #A": true,
              "__name__": true,
              "agent_id": true,
              "job": true,
              "instance": true
            },
            "indexByName": {
              "agent_name": 0,
              "Value #B": 1,
              "Value #C": 2,
              "Value #D": 3,
              "version": 4,
              "site": 5,
              "platform": 6
            },
            "renameByName": {
              "agent_name": "Agent",
              "site": "Site",
              "version": "Version",
              "platform": "Platform",
              "Value #B": "State",
              "Value #C": "Last heartbeat",
              "Value #D": "Load"
            }
          }
        }
      ]
    },
    {
      "id": 20,
      "type": "row",
      "title": "AI models",
      "collapsed": true,
      "gridPos": {
        "x": 0,
        "y": 53,
        "w": 24,
        "h": 1
      },
      "panels": [
        {
          "id": 18,
          "type": "timeseries",
          "title": "Time to first token",
          "description": "AI model monitors: time to the first token of the last check.",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "gridPos": {
            "x": 0,
            "y": 54,
            "w": 12,
            "h": 8
          },
          "targets": [
            {
              "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
              },
              "expr": "okstatus_llm_time_to_first_token_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\", probe_region=~\"$region\"}",
              "refId": "A",
              "legendFormat": "{{monitor_name}} · {{probe_region}}",
              "range": true,
              "instant": false
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "s",
              "custom": {
                "lineWidth": 2,
                "fillOpacity": 6,
                "showPoints": "never",
                "spanNulls": true
              }
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          }
        },
        {
          "id": 19,
          "type": "timeseries",
          "title": "Time per output token",
          "description": "AI model monitors: mean time per output token after the first.",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "gridPos": {
            "x": 12,
            "y": 54,
            "w": 12,
            "h": 8
          },
          "targets": [
            {
              "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
              },
              "expr": "okstatus_llm_time_per_output_token_seconds{monitor_group=~\"$group\", monitor_name=~\"$monitor\", probe_region=~\"$region\"}",
              "refId": "A",
              "legendFormat": "{{monitor_name}} · {{probe_region}}",
              "range": true,
              "instant": false
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "s",
              "custom": {
                "lineWidth": 2,
                "fillOpacity": 6,
                "showPoints": "never",
                "spanNulls": true
              }
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "list",
              "placement": "bottom"
            },
            "tooltip": {
              "mode": "multi"
            }
          }
        }
      ]
    },
    {
      "id": 23,
      "type": "row",
      "title": "SLA detail",
      "collapsed": true,
      "gridPos": {
        "x": 0,
        "y": 54,
        "w": 24,
        "h": 1
      },
      "panels": [
        {
          "id": 21,
          "type": "bargauge",
          "title": "Downtime · $window",
          "description": "Time spent down over the window, monitors with downtime only.",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "gridPos": {
            "x": 0,
            "y": 55,
            "w": 12,
            "h": 9
          },
          "targets": [
            {
              "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
              },
              "expr": "okstatus_monitor_downtime_seconds{window=\"$window\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"} > 0",
              "refId": "A",
              "legendFormat": "{{monitor_name}}",
              "range": false,
              "instant": true
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "s",
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "#FF9830",
                    "value": null
                  },
                  {
                    "color": "red",
                    "value": 3600
                  }
                ]
              },
              "color": {
                "mode": "thresholds"
              }
            },
            "overrides": []
          },
          "options": {
            "orientation": "horizontal",
            "displayMode": "gradient",
            "valueMode": "color",
            "namePlacement": "left",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            }
          }
        },
        {
          "id": 22,
          "type": "bargauge",
          "title": "Error budget left per monitor · $window",
          "description": "Monitor SLA target when set, organization target otherwise.",
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "gridPos": {
            "x": 12,
            "y": 55,
            "w": 12,
            "h": 9
          },
          "targets": [
            {
              "datasource": {
                "type": "prometheus",
                "uid": "${datasource}"
              },
              "expr": "clamp(\n  1 - (1 - okstatus_monitor_availability_ratio{window=\"$window\", monitor_group=~\"$group\", monitor_name=~\"$monitor\"})\n    / on (monitor_id) group_left ()\n      (1 - (okstatus_monitor_sla_target_ratio or on (monitor_id) (0 * okstatus_monitor_check_interval_seconds + scalar(okstatus_org_sla_target_ratio)))),\n  0, 1)",
              "refId": "A",
              "legendFormat": "{{monitor_name}}",
              "range": false,
              "instant": true
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "percentunit",
              "decimals": 0,
              "min": 0,
              "max": 1,
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "red",
                    "value": null
                  },
                  {
                    "color": "#FF9830",
                    "value": 0.2
                  },
                  {
                    "color": "green",
                    "value": 0.5
                  }
                ]
              },
              "color": {
                "mode": "thresholds"
              }
            },
            "overrides": []
          },
          "options": {
            "orientation": "horizontal",
            "displayMode": "lcd",
            "showUnfilled": true,
            "valueMode": "color",
            "namePlacement": "left",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            }
          }
        }
      ]
    }
  ]
}
