{
  "id": null,
  "uid": "mikrotik-infrastructure",
  "title": "Infrastructure",
  "description": "TOD service health and availability overview",
  "tags": ["mikrotik", "infrastructure"],
  "timezone": "browser",
  "schemaVersion": 39,
  "version": 1,
  "refresh": "30s",
  "editable": true,
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "panels": [
    {
      "id": 1,
      "title": "API Up",
      "type": "stat",
      "gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 },
      "datasource": "Prometheus",
      "targets": [
        {
          "expr": "up{job=\"mikrotik-api\"}",
          "legendFormat": "API",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            { "type": "value", "options": { "0": { "text": "DOWN", "color": "red" }, "1": { "text": "UP", "color": "green" } } }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "red", "value": null },
              { "color": "green", "value": 1 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": { "calcs": ["lastNotNull"] },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "auto"
      }
    },
    {
      "id": 2,
      "title": "Poller Up",
      "type": "stat",
      "gridPos": { "h": 5, "w": 6, "x": 6, "y": 0 },
      "datasource": "Prometheus",
      "targets": [
        {
          "expr": "up{job=\"mikrotik-poller\"}",
          "legendFormat": "Poller",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "mappings": [
            { "type": "value", "options": { "0": { "text": "DOWN", "color": "red" }, "1": { "text": "UP", "color": "green" } } }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "red", "value": null },
              { "color": "green", "value": 1 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": { "calcs": ["lastNotNull"] },
        "colorMode": "background",
        "graphMode": "none",
        "textMode": "auto"
      }
    },
    {
      "id": 3,
      "title": "API Requests/s",
      "type": "stat",
      "gridPos": { "h": 5, "w": 6, "x": 12, "y": 0 },
      "datasource": "Prometheus",
      "targets": [
        {
          "expr": "sum(rate(http_requests_total[5m]))",
          "legendFormat": "Requests/s",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "blue", "value": null }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": { "calcs": ["lastNotNull"] },
        "colorMode": "value",
        "graphMode": "area"
      }
    },
    {
      "id": 4,
      "title": "Polls/s",
      "type": "stat",
      "gridPos": { "h": 5, "w": 6, "x": 18, "y": 0 },
      "datasource": "Prometheus",
      "targets": [
        {
          "expr": "sum(rate(mikrotik_poll_total[5m]))",
          "legendFormat": "Polls/s",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "ops",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "blue", "value": null }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": { "calcs": ["lastNotNull"] },
        "colorMode": "value",
        "graphMode": "area"
      }
    },
    {
      "id": 5,
      "title": "Service Availability",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 5 },
      "datasource": "Prometheus",
      "targets": [
        {
          "expr": "up",
          "legendFormat": "{{job}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "min": 0,
          "max": 1,
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "stepAfter",
            "fillOpacity": 30,
            "pointSize": 5,
            "showPoints": "always"
          },
          "mappings": [
            { "type": "value", "options": { "0": { "text": "DOWN" }, "1": { "text": "UP" } } }
          ]
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi" },
        "legend": { "displayMode": "list", "placement": "bottom" }
      }
    },
    {
      "id": 6,
      "title": "API 5xx Error Rate",
      "type": "timeseries",
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 5 },
      "datasource": "Prometheus",
      "targets": [
        {
          "expr": "sum(rate(http_requests_total{status=~\"5..\"}[5m]))",
          "legendFormat": "5xx errors/s",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 20
          },
          "color": { "mode": "fixed", "fixedColor": "red" },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "red", "value": 0.1 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "single" },
        "legend": { "displayMode": "list", "placement": "bottom" }
      }
    }
  ]
}
