{
  "__inputs": [
    { "name": "DS_PROMETHEUS", "label": "Prometheus / Mimir", "description": "Where your Windows metrics land", "type": "datasource", "pluginId": "prometheus", "pluginName": "Prometheus" },
    { "name": "DS_LOKI", "label": "Loki", "description": "Where your Windows Event Log lands", "type": "datasource", "pluginId": "loki", "pluginName": "Loki" }
  ],
  "__requires": [
    { "type": "grafana", "id": "grafana", "name": "Grafana", "version": "11.0.0" },
    { "type": "datasource", "id": "prometheus", "name": "Prometheus", "version": "1.0.0" },
    { "type": "datasource", "id": "loki", "name": "Loki", "version": "1.0.0" }
  ],
  "annotations": { "list": [] },
  "editable": true,
  "graphTooltip": 1,
  "time": { "from": "now-6h", "to": "now" },
  "timezone": "",
  "title": "Windows Server — OpenTelemetry",
  "tags": ["windows", "opentelemetry", "linkmesh"],
  "schemaVersion": 39,
  "version": 2,
  "templating": {
    "list": [
      {
        "name": "host",
        "label": "Server",
        "type": "query",
        "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
        "definition": "label_values(system_cpu_utilization_ratio, host_name)",
        "query": { "query": "label_values(system_cpu_utilization_ratio, host_name)", "refId": "hostVar" },
        "refresh": 2,
        "sort": 1,
        "includeAll": false,
        "multi": false
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "title": "CPU busy %",
      "type": "timeseries",
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
      "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0, "max": 1 }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "1 - avg by (host_name) (system_cpu_utilization_ratio{host_name=\"$host\", state=\"idle\"})", "legendFormat": "CPU busy" }
      ]
    },
    {
      "id": 2,
      "title": "Memory used %",
      "type": "timeseries",
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
      "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0, "max": 1 }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "sum by (host_name) (system_memory_utilization_ratio{host_name=\"$host\", state=~\"used|buffered|cached\"})", "legendFormat": "Memory used" }
      ]
    },
    {
      "id": 3,
      "title": "Disk free % (by volume)",
      "type": "timeseries",
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
      "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0, "max": 1 }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "system_filesystem_utilization_ratio{host_name=\"$host\", state=\"free\"}", "legendFormat": "{{device}}" }
      ]
    },
    {
      "id": 4,
      "title": "Network throughput",
      "type": "timeseries",
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 },
      "fieldConfig": { "defaults": { "unit": "Bps" }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "sum by (direction) (rate(system_network_io_bytes_total{host_name=\"$host\"}[5m]))", "legendFormat": "{{direction}}" }
      ]
    },
    {
      "id": 5,
      "title": "Server reporting",
      "type": "stat",
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "gridPos": { "h": 6, "w": 6, "x": 0, "y": 16 },
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "mappings": [
            { "type": "value", "options": { "0": { "text": "No data", "color": "red" } } },
            { "type": "range", "options": { "from": 1, "to": 1000000, "result": { "text": "Reporting", "color": "green" } } }
          ],
          "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 1 } ] }
        },
        "overrides": []
      },
      "options": { "reduceOptions": { "calcs": ["lastNotNull"] }, "colorMode": "background", "graphMode": "none" },
      "targets": [
        { "refId": "A", "expr": "count(system_cpu_utilization_ratio{host_name=\"$host\"})", "legendFormat": "reporting" }
      ]
    },
    {
      "id": 6,
      "title": "Failed logins (Security 4625)",
      "type": "timeseries",
      "datasource": { "type": "loki", "uid": "${DS_LOKI}" },
      "gridPos": { "h": 6, "w": 9, "x": 6, "y": 16 },
      "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "sum(count_over_time({host_name=\"$host\"} |~ `(?i)(4625|failed to log on)` [$__interval]))", "legendFormat": "failed logins" }
      ]
    },
    {
      "id": 7,
      "title": "Reboots & shutdowns (System)",
      "type": "timeseries",
      "datasource": { "type": "loki", "uid": "${DS_LOKI}" },
      "gridPos": { "h": 6, "w": 9, "x": 15, "y": 16 },
      "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "sum(count_over_time({host_name=\"$host\"} |~ `(?i)(6005|6006|6008|1074|has rebooted|shutdown was initiated)` [$__interval]))", "legendFormat": "reboots/shutdowns" }
      ]
    },
    {
      "id": 8,
      "title": "Service failures (System 7031/7034)",
      "type": "timeseries",
      "datasource": { "type": "loki", "uid": "${DS_LOKI}" },
      "gridPos": { "h": 6, "w": 12, "x": 0, "y": 22 },
      "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "sum(count_over_time({host_name=\"$host\"} |~ `(?i)(7031|7034|terminated unexpectedly)` [$__interval]))", "legendFormat": "service failures" }
      ]
    },
    {
      "id": 9,
      "title": "Event Log — errors & critical",
      "type": "timeseries",
      "datasource": { "type": "loki", "uid": "${DS_LOKI}" },
      "gridPos": { "h": 6, "w": 12, "x": 12, "y": 22 },
      "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] },
      "targets": [
        { "refId": "A", "expr": "sum(count_over_time({host_name=\"$host\"} | severity_text =~ `(?i)error|critical` [$__interval]))", "legendFormat": "errors" }
      ]
    },
    {
      "id": 10,
      "title": "Windows Event Log",
      "type": "logs",
      "datasource": { "type": "loki", "uid": "${DS_LOKI}" },
      "gridPos": { "h": 10, "w": 24, "x": 0, "y": 28 },
      "options": { "showTime": true, "wrapLogMessage": true, "sortOrder": "Descending" },
      "targets": [
        { "refId": "A", "expr": "{host_name=\"$host\"}" }
      ]
    }
  ]
}
