{
  "title": "waylight",
  "uid": "waylight",
  "schemaVersion": 39,
  "version": 1,
  "editable": true,
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "refresh": "1m",
  "tags": [
    "waylight"
  ],
  "templating": {
    "list": [
      {
        "name": "datasource",
        "type": "datasource",
        "query": "prometheus",
        "label": "Data source"
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "stat",
      "title": "Services up",
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum(waylight_service_up) / count(waylight_service_up)"
        }
      ]
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Containers running",
      "gridPos": {
        "x": 6,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "waylight_containers{state=\"running\"}"
        }
      ]
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Failing backups/checks",
      "gridPos": {
        "x": 12,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "count(waylight_backup_ok == 0) or vector(0)"
        }
      ]
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Host uptime",
      "gridPos": {
        "x": 18,
        "y": 0,
        "w": 6,
        "h": 4
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "s"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "waylight_host_uptime_seconds"
        }
      ]
    },
    {
      "id": 5,
      "type": "timeseries",
      "title": "Service availability",
      "gridPos": {
        "x": 0,
        "y": 4,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "waylight_service_up",
          "legendFormat": "{{service}}"
        }
      ]
    },
    {
      "id": 6,
      "type": "timeseries",
      "title": "Service response time",
      "gridPos": {
        "x": 12,
        "y": 4,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "s"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "waylight_service_response_seconds",
          "legendFormat": "{{service}}"
        }
      ]
    },
    {
      "id": 7,
      "type": "timeseries",
      "title": "Host CPU and memory",
      "gridPos": {
        "x": 0,
        "y": 12,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "waylight_host_cpu_ratio",
          "legendFormat": "CPU"
        },
        {
          "refId": "B",
          "expr": "waylight_host_memory_used_bytes / waylight_host_memory_total_bytes",
          "legendFormat": "Memory"
        }
      ]
    },
    {
      "id": 8,
      "type": "timeseries",
      "title": "Disk usage",
      "gridPos": {
        "x": 12,
        "y": 12,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "waylight_host_disk_used_bytes / waylight_host_disk_total_bytes",
          "legendFormat": "{{disk}}"
        }
      ]
    },
    {
      "id": 9,
      "type": "timeseries",
      "title": "Days until certificates expire",
      "gridPos": {
        "x": 0,
        "y": 20,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "d"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "(waylight_service_cert_expiry_timestamp_seconds - time()) / 86400",
          "legendFormat": "{{service}}"
        }
      ]
    },
    {
      "id": 10,
      "type": "timeseries",
      "title": "Hours since last successful backup",
      "gridPos": {
        "x": 12,
        "y": 20,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "h"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "(time() - waylight_backup_last_success_timestamp_seconds) / 3600",
          "legendFormat": "{{name}}"
        }
      ]
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "HTTP requests",
      "gridPos": {
        "x": 0,
        "y": 28,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "reqps"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by (code) (rate(waylight_http_requests_total[5m]))",
          "legendFormat": "{{code}}"
        }
      ]
    },
    {
      "id": 12,
      "type": "timeseries",
      "title": "Go runtime",
      "gridPos": {
        "x": 12,
        "y": 28,
        "w": 12,
        "h": 8
      },
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short"
        },
        "overrides": []
      },
      "targets": [
        {
          "refId": "A",
          "expr": "go_goroutines",
          "legendFormat": "goroutines"
        },
        {
          "refId": "B",
          "expr": "go_memstats_heap_alloc_bytes / 1e6",
          "legendFormat": "heap MB"
        }
      ]
    }
  ]
}
