{
  "title": "OnlineOrNot",
  "uid": "onlineornot-prometheus",
  "description": "OnlineOrNot checks and heartbeats from the Prometheus export.",
  "tags": [
    "onlineornot"
  ],
  "editable": true,
  "graphTooltip": 1,
  "schemaVersion": 39,
  "version": 1,
  "refresh": "1m",
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "links": [
    {
      "title": "OnlineOrNot",
      "type": "link",
      "url": "https://onlineornot.com/app",
      "targetBlank": true,
      "icon": "external link"
    }
  ],
  "annotations": {
    "list": []
  },
  "templating": {
    "list": [
      {
        "name": "datasource",
        "label": "Data source",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 0,
        "refresh": 1
      },
      {
        "name": "job",
        "label": "Scrape job",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(oon_export_info, job)",
          "refId": "job",
          "qryType": 1
        },
        "definition": "label_values(oon_export_info, job)",
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1
      },
      {
        "name": "project",
        "label": "Project",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(oon_monitor_info{job=~\"$job\"}, project_name)",
          "refId": "project",
          "qryType": 1
        },
        "definition": "label_values(oon_monitor_info{job=~\"$job\"}, project_name)",
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1
      },
      {
        "name": "check_type",
        "label": "Type",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(oon_monitor_info{job=~\"$job\"}, check_type)",
          "refId": "check_type",
          "qryType": 1
        },
        "definition": "label_values(oon_monitor_info{job=~\"$job\"}, check_type)",
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1
      },
      {
        "name": "monitor",
        "label": "Monitor",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(oon_monitor_info{job=~\"$job\", project_name=~\"$project\", check_type=~\"$check_type\"}, name)",
          "refId": "monitor",
          "qryType": 1
        },
        "definition": "label_values(oon_monitor_info{job=~\"$job\", project_name=~\"$project\", check_type=~\"$check_type\"}, name)",
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1
      },
      {
        "name": "region",
        "label": "Region",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(oon_check_results_total{job=~\"$job\"}, region)",
          "refId": "region",
          "qryType": 1
        },
        "definition": "label_values(oon_check_results_total{job=~\"$job\"}, region)",
        "refresh": 2,
        "multi": true,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "sort": 1,
        "description": "Needs per_region=true in the scrape config."
      },
      {
        "name": "window",
        "label": "Window",
        "type": "custom",
        "query": "15m,1h,6h,1d",
        "current": {
          "text": "1h",
          "value": "1h"
        },
        "options": [
          {
            "text": "15m",
            "value": "15m",
            "selected": false
          },
          {
            "text": "1h",
            "value": "1h",
            "selected": true
          },
          {
            "text": "6h",
            "value": "6h",
            "selected": false
          },
          {
            "text": "1d",
            "value": "1d",
            "selected": false
          }
        ],
        "multi": false,
        "includeAll": false,
        "hide": 0,
        "description": "Use a longer window for checks that run less often."
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "stat",
      "title": "Checks exported",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "(count(oon_export_info{job=~\"$job\", checks=\"no_permission\"}) * 0) or max(oon_export_info{job=~\"$job\"})",
          "refId": "A"
        }
      ],
      "description": "Shows \"Not exported\" when the API token cannot read checks. Give the token UPTIME_CHECKS:READ to export them.",
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "Not exported",
                  "color": "red",
                  "index": 0
                },
                "1": {
                  "text": "Exported",
                  "color": "green",
                  "index": 1
                }
              }
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Heartbeats exported",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 4,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "(count(oon_export_info{job=~\"$job\", heartbeats=\"no_permission\"}) * 0) or max(oon_export_info{job=~\"$job\"})",
          "refId": "A"
        }
      ],
      "description": "Shows \"Not exported\" when the API token cannot read heartbeats. Give the token HEARTBEAT_CHECKS:READ to export them.",
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "Not exported",
                  "color": "red",
                  "index": 0
                },
                "1": {
                  "text": "Exported",
                  "color": "green",
                  "index": 1
                }
              }
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Scrape",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 8,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "min(up{job=~\"$job\"})",
          "refId": "A"
        }
      ],
      "description": "Whether Prometheus could scrape OnlineOrNot on its last attempt. No data means no scrape job matches.",
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "mappings": [
            {
              "type": "value",
              "options": {
                "0": {
                  "text": "Failing",
                  "color": "red",
                  "index": 0
                },
                "1": {
                  "text": "OK",
                  "color": "green",
                  "index": 1
                }
              }
            }
          ],
          "noValue": "No scrape job",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "green",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Monitors by state",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 0,
        "w": 12,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "count by (state) ((oon_monitor_status{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\"} == 1) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"})",
          "refId": "A",
          "legendFormat": "{{state}}",
          "instant": true
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name",
        "justifyMode": "center",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "fixed",
            "fixedColor": "blue"
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "DOWN"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "red"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "UP"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "green"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "VERIFYING"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "orange"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "RECOVERING"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "yellow"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "PAUSED"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "text"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "MAINTENANCE"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "purple"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "MUTED"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "text"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "PENDING"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "text"
                }
              }
            ]
          }
        ]
      }
    },
    {
      "id": 5,
      "type": "table",
      "title": "Down",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 4,
        "w": 12,
        "h": 6
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "label_replace(label_replace((oon_monitor_status{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", state=\"DOWN\"} == 1) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"}, \"page\", \"heartbeats\", \"check_type\", \"HEARTBEAT\"), \"page\", \"checks\", \"check_type\", \"UPTIME|BROWSER|DNS|TCP\")",
          "refId": "A",
          "instant": true,
          "format": "table"
        }
      ],
      "description": "Monitors OnlineOrNot has confirmed are down.",
      "fieldConfig": {
        "defaults": {
          "noValue": "Nothing is down"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "monitor_id"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "page"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "name"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Open in OnlineOrNot",
                    "url": "https://onlineornot.com/app/${__data.fields.page}/${__data.fields.monitor_id}",
                    "targetBlank": true
                  }
                ]
              },
              {
                "id": "displayName",
                "value": "Monitor"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "check_type"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Type"
              }
            ]
          }
        ]
      },
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value": true,
              "__name__": true,
              "job": true,
              "instance": true,
              "state": true
            },
            "indexByName": {
              "name": 0,
              "check_type": 1
            }
          }
        }
      ]
    },
    {
      "id": 6,
      "type": "table",
      "title": "Verifying, recovering, paused or in maintenance",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 4,
        "w": 12,
        "h": 6
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "label_replace(label_replace((oon_monitor_status{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", state=~\"VERIFYING|RECOVERING|PAUSED|MAINTENANCE\"} == 1) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"}, \"page\", \"heartbeats\", \"check_type\", \"HEARTBEAT\"), \"page\", \"checks\", \"check_type\", \"UPTIME|BROWSER|DNS|TCP\")",
          "refId": "A",
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "noValue": "None"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "monitor_id"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "page"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "name"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Open in OnlineOrNot",
                    "url": "https://onlineornot.com/app/${__data.fields.page}/${__data.fields.monitor_id}",
                    "targetBlank": true
                  }
                ]
              },
              {
                "id": "displayName",
                "value": "Monitor"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "check_type"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Type"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "state"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "State"
              }
            ]
          }
        ]
      },
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value": true,
              "__name__": true,
              "job": true,
              "instance": true
            },
            "indexByName": {
              "name": 0,
              "check_type": 1,
              "state": 2
            }
          }
        }
      ]
    },
    {
      "id": 7,
      "type": "table",
      "title": "Monitors",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 10,
        "w": 24,
        "h": 12
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name, project_name, page) (label_replace(label_replace(oon_monitor_info{job=~\"$job\", project_name=~\"$project\", check_type=~\"$check_type\", name=~\"$monitor\"}, \"page\", \"heartbeats\", \"check_type\", \"HEARTBEAT\"), \"page\", \"checks\", \"check_type\", \"UPTIME|BROWSER|DNS|TCP\"))",
          "refId": "A",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name, state) (oon_monitor_status{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\"} == 1)",
          "refId": "B",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "time() - max by (monitor_id, check_type, name) (oon_monitor_last_result_timestamp_seconds{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\"})",
          "refId": "C",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name) (oon_check_interval_seconds{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\"})",
          "refId": "D",
          "instant": true,
          "format": "table"
        }
      ],
      "description": "Last result is the latest check result, or the latest ping for heartbeats. An empty cell means no result has been recorded yet.",
      "fieldConfig": {
        "defaults": {},
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "monitor_id"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "page"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "name"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Open in OnlineOrNot",
                    "url": "https://onlineornot.com/app/${__data.fields.page}/${__data.fields.monitor_id}",
                    "targetBlank": true
                  }
                ]
              },
              {
                "id": "displayName",
                "value": "Monitor"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "check_type"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Type"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "project_name"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Project"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "state"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "State"
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              },
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "text"
                }
              },
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "DOWN": {
                        "color": "red",
                        "index": 0
                      },
                      "UP": {
                        "color": "green",
                        "index": 1
                      },
                      "VERIFYING": {
                        "color": "orange",
                        "index": 2
                      },
                      "RECOVERING": {
                        "color": "yellow",
                        "index": 3
                      },
                      "PAUSED": {
                        "color": "text",
                        "index": 4
                      },
                      "MAINTENANCE": {
                        "color": "purple",
                        "index": 5
                      }
                    }
                  }
                ]
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #C"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Last result"
              },
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #D"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Check interval"
              },
              {
                "id": "unit",
                "value": "s"
              }
            ]
          }
        ]
      },
      "transformations": [
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value #A": true,
              "Value #B": true,
              "__name__": true,
              "job": true,
              "instance": true,
              "project_id": true
            },
            "indexByName": {
              "name": 0,
              "check_type": 1,
              "project_name": 2,
              "state": 3,
              "Value #C": 4,
              "Value #D": 5
            }
          }
        },
        {
          "id": "sortBy",
          "options": {
            "sort": [
              {
                "field": "name"
              }
            ]
          }
        }
      ]
    },
    {
      "id": 8,
      "type": "timeseries",
      "title": "Failure ratio",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 22,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (monitor_id, check_type, name, region) (increase(oon_check_results_total{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", region=~\"$region\", outcome=\"failing\"}[$window]) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"})\n/\n(sum by (monitor_id, check_type, name, region) (increase(oon_check_results_total{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", region=~\"$region\"}[$window]) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"}) > 0)",
          "refId": "A",
          "legendFormat": "{{name}} {{region}}"
        }
      ],
      "description": "Share of results that failed over the selected window. Gaps mean there were no results in the window.",
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "min": 0,
          "max": 1,
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 0,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "calcs": [
            "max",
            "lastNotNull"
          ]
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 9,
      "type": "timeseries",
      "title": "Duration p95 by check type",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 22,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "histogram_quantile(0.95, sum by (le, check_type, region) (rate(oon_check_duration_seconds_bucket{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", region=~\"$region\"}[$window]) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"}))",
          "refId": "A",
          "legendFormat": "{{check_type}} {{region}}"
        }
      ],
      "description": "Includes passing and failing results. Timeouts raise it and fast connection failures lower it.",
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "min": 0,
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 0,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "calcs": [
            "mean",
            "lastNotNull"
          ]
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 10,
      "type": "timeseries",
      "title": "Duration p95 by monitor",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 30,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "histogram_quantile(0.95, sum by (le, monitor_id, check_type, name) (rate(oon_check_duration_seconds_bucket{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", region=~\"$region\"}[$window]) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"}))",
          "refId": "A",
          "legendFormat": "{{name}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "min": 0,
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 0,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "calcs": [
            "mean",
            "lastNotNull"
          ]
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "Results per minute",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 12,
        "y": 30,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "sum by (outcome) (rate(oon_check_results_total{job=~\"$job\", check_type=~\"$check_type\", name=~\"$monitor\", region=~\"$region\"}[$window]) and on (monitor_id, check_type) oon_monitor_info{job=~\"$job\", project_name=~\"$project\"}) * 60",
          "refId": "A",
          "legendFormat": "{{outcome}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "min": 0,
          "custom": {
            "drawStyle": "line",
            "lineWidth": 1,
            "fillOpacity": 10,
            "stacking": {
              "mode": "normal"
            }
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "failing"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "red"
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "passing"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "green"
                }
              }
            ]
          }
        ]
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom"
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 12,
      "type": "table",
      "title": "Heartbeats",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "x": 0,
        "y": 38,
        "w": 24,
        "h": 7
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name, project_name, page) (label_replace(label_replace(oon_monitor_info{job=~\"$job\", project_name=~\"$project\", check_type=\"HEARTBEAT\", name=~\"$monitor\"}, \"page\", \"heartbeats\", \"check_type\", \"HEARTBEAT\"), \"page\", \"checks\", \"check_type\", \"UPTIME|BROWSER|DNS|TCP\"))",
          "refId": "A",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "time() - max by (monitor_id, check_type, name) (oon_monitor_last_result_timestamp_seconds{job=~\"$job\", check_type=\"HEARTBEAT\", name=~\"$monitor\"})",
          "refId": "B",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name) (oon_heartbeat_next_due_timestamp_seconds{job=~\"$job\", check_type=\"HEARTBEAT\", name=~\"$monitor\"}) - time()",
          "refId": "C",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name) (oon_heartbeat_expected_interval_seconds{job=~\"$job\", check_type=\"HEARTBEAT\", name=~\"$monitor\"})",
          "refId": "D",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name) (oon_heartbeat_grace_period_seconds{job=~\"$job\", check_type=\"HEARTBEAT\", name=~\"$monitor\"})",
          "refId": "E",
          "instant": true,
          "format": "table"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "expr": "max by (monitor_id, check_type, name) (oon_heartbeat_overdue{job=~\"$job\", check_type=\"HEARTBEAT\", name=~\"$monitor\"})",
          "refId": "F",
          "instant": true,
          "format": "table"
        }
      ],
      "description": "Due in is negative once the ping is late. Interval is empty for heartbeats on a cron schedule.",
      "fieldConfig": {
        "defaults": {},
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "monitor_id"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "page"
            },
            "properties": [
              {
                "id": "custom.hidden",
                "value": true
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "name"
            },
            "properties": [
              {
                "id": "links",
                "value": [
                  {
                    "title": "Open in OnlineOrNot",
                    "url": "https://onlineornot.com/app/${__data.fields.page}/${__data.fields.monitor_id}",
                    "targetBlank": true
                  }
                ]
              },
              {
                "id": "displayName",
                "value": "Heartbeat"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "project_name"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Project"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #B"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Last ping"
              },
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #C"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Due in"
              },
              {
                "id": "unit",
                "value": "s"
              },
              {
                "id": "decimals",
                "value": 0
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #D"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Interval"
              },
              {
                "id": "unit",
                "value": "s"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #E"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Grace period"
              },
              {
                "id": "unit",
                "value": "s"
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "Value #F"
            },
            "properties": [
              {
                "id": "displayName",
                "value": "Overdue"
              },
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "color-text"
                }
              },
              {
                "id": "color",
                "value": {
                  "mode": "thresholds"
                }
              },
              {
                "id": "thresholds",
                "value": {
                  "mode": "absolute",
                  "steps": [
                    {
                      "color": "text",
                      "value": null
                    },
                    {
                      "color": "red",
                      "value": 1
                    }
                  ]
                }
              },
              {
                "id": "mappings",
                "value": [
                  {
                    "type": "value",
                    "options": {
                      "0": {
                        "text": "No",
                        "index": 0
                      },
                      "1": {
                        "text": "Yes",
                        "index": 1
                      }
                    }
                  }
                ]
              }
            ]
          }
        ]
      },
      "transformations": [
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "Value #A": true,
              "__name__": true,
              "job": true,
              "instance": true,
              "project_id": true,
              "check_type": true
            },
            "indexByName": {
              "name": 0,
              "project_name": 1,
              "Value #B": 2,
              "Value #C": 3,
              "Value #D": 4,
              "Value #E": 5,
              "Value #F": 6
            }
          }
        },
        {
          "id": "sortBy",
          "options": {
            "sort": [
              {
                "field": "name"
              }
            ]
          }
        }
      ]
    }
  ]
}
