{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "10.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    }
  ],
  "title": "HyperCloud",
  "uid": "hypercloud",
  "tags": ["hypercloud"],
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "refresh": "1m",
  "editable": true,
  "description": "The numbers that say a HyperCloud instance has quietly stopped doing its job. See docs/metrics.md.",
  "templating": {
    "list": []
  },
  "annotations": {
    "list": []
  },
  "panels": [
    {
      "id": 1,
      "type": "row",
      "title": "Health",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Since last reminder pass",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 0,
        "y": 1,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "time() - hypercloud_reminder_scheduler_last_tick_timestamp_seconds",
          "legendFormat": ""
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 90
              },
              {
                "color": "red",
                "value": 300
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name"
      },
      "description": "The scheduler runs every 30 s. Empty when Web Push is not configured."
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Failing sync links",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 6,
        "y": 1,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "sum by (kind) (hypercloud_sync_links{state=\"failing\"})",
          "legendFormat": "{{kind}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 1
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name"
      },
      "description": "Links whose last sync ended in an error."
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Backup age",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 12,
        "y": 1,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "time() - hypercloud_backup_last_success_timestamp_seconds",
          "legendFormat": "{{kind}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 93600
              },
              {
                "color": "red",
                "value": 172800
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name"
      }
    },
    {
      "id": 5,
      "type": "stat",
      "title": "Database size",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 18,
        "y": 1,
        "w": 6,
        "h": 4
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "hypercloud_db_size_bytes",
          "legendFormat": ""
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "bytes"
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "value_and_name"
      }
    },
    {
      "id": 6,
      "type": "row",
      "title": "Reminders",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 5,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 7,
      "type": "timeseries",
      "title": "Reminder lag",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 0,
        "y": 6,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "histogram_quantile(0.5, sum by (le) (rate(hypercloud_reminder_scheduler_lag_seconds_bucket[$__rate_interval])))",
          "legendFormat": "p50"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "B",
          "expr": "histogram_quantile(0.95, sum by (le) (rate(hypercloud_reminder_scheduler_lag_seconds_bucket[$__rate_interval])))",
          "legendFormat": "p95"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "description": "How long after its scheduled instant each reminder went out. Ticks are 30 s apart, so up to 30 s is normal."
    },
    {
      "id": 8,
      "type": "timeseries",
      "title": "Reminder deliveries",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 12,
        "y": 6,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "sum by (status) (increase(hypercloud_reminders_sent_total[$__rate_interval]))",
          "legendFormat": "{{status}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "description": "One per device. gone: the device unsubscribed and was removed."
    },
    {
      "id": 9,
      "type": "row",
      "title": "Sync",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 14,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 10,
      "type": "timeseries",
      "title": "Sync passes",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 0,
        "y": 15,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "sum by (kind, result) (increase(hypercloud_dav_sync_runs_total[$__rate_interval]))",
          "legendFormat": "{{kind}} {{result}}"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "B",
          "expr": "sum by (result) (increase(hypercloud_subscription_fetches_total[$__rate_interval]))",
          "legendFormat": "ics {{result}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "Oldest successful sync",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 12,
        "y": 15,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "time() - hypercloud_sync_oldest_success_timestamp_seconds",
          "legendFormat": "{{kind}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "description": "Age of the least recently synced link of each kind."
    },
    {
      "id": 12,
      "type": "row",
      "title": "HTTP",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 23,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 13,
      "type": "timeseries",
      "title": "Requests by status",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 0,
        "y": 24,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "sum by (status) (rate(hypercloud_http_requests_total[$__rate_interval]))",
          "legendFormat": "{{status}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 14,
      "type": "timeseries",
      "title": "p95 latency by route (top 10)",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 12,
        "y": 24,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "topk(10, histogram_quantile(0.95, sum by (le, route) (rate(hypercloud_http_request_duration_seconds_bucket[$__rate_interval]))))",
          "legendFormat": "{{route}}"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 15,
      "type": "row",
      "title": "Process",
      "collapsed": false,
      "gridPos": {
        "x": 0,
        "y": 32,
        "w": 24,
        "h": 1
      },
      "panels": []
    },
    {
      "id": 16,
      "type": "timeseries",
      "title": "Memory",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 0,
        "y": 33,
        "w": 12,
        "h": 6
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "process_resident_memory_bytes",
          "legendFormat": "rss"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "bytes"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    },
    {
      "id": 17,
      "type": "timeseries",
      "title": "CPU",
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "gridPos": {
        "x": 12,
        "y": 33,
        "w": 12,
        "h": 6
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "refId": "A",
          "expr": "rate(process_cpu_seconds_total[$__rate_interval])",
          "legendFormat": "cpu"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit"
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      }
    }
  ]
}
