{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Device monitoring dashboard powered by mikr /metrics endpoint",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "links": [],
  "panels": [
    {
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
      "id": 1,
      "panels": [],
      "title": "Fleet Summary",
      "type": "row"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "fixedColor": "text", "mode": "fixed" },
          "mappings": [],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "text", "value": 0 }] }
        },
        "overrides": []
      },
      "gridPos": { "h": 4, "w": 4, "x": 0, "y": 1 },
      "id": 2,
      "options": {
        "colorMode": "value", "graphMode": "none", "justifyMode": "auto", "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
        "showPercentChange": false, "textMode": "auto", "wideLayout": true
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_devices_total", "legendFormat": "Total", "refId": "A" }],
      "title": "Total Devices",
      "type": "stat"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "fixedColor": "green", "mode": "fixed" },
          "mappings": [],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }] }
        },
        "overrides": []
      },
      "gridPos": { "h": 4, "w": 4, "x": 4, "y": 1 },
      "id": 3,
      "options": {
        "colorMode": "value", "graphMode": "area", "justifyMode": "auto", "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
        "showPercentChange": false, "textMode": "auto", "wideLayout": true
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_devices_online", "legendFormat": "Online", "refId": "A" }],
      "title": "Online",
      "type": "stat"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "fixedColor": "red", "mode": "fixed" },
          "mappings": [],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 1 }] }
        },
        "overrides": []
      },
      "gridPos": { "h": 4, "w": 4, "x": 8, "y": 1 },
      "id": 4,
      "options": {
        "colorMode": "value", "graphMode": "area", "justifyMode": "auto", "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
        "showPercentChange": false, "textMode": "auto", "wideLayout": true
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_devices_total - mikr_devices_online", "legendFormat": "Offline", "refId": "A" }],
      "title": "Offline",
      "type": "stat"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": { "color": { "mode": "palette-classic" }, "custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } }, "mappings": [] },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 6, "x": 12, "y": 1 },
      "id": 5,
      "options": {
        "legend": { "displayMode": "table", "placement": "right", "showLegend": true, "values": ["value"] },
        "pieType": "donut",
        "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
        "sort": "desc",
        "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "count by (routeros) (mikr_device_info{name=~\"$device\", site=~\"$site\"})", "legendFormat": "{{routeros}}", "refId": "A" }],
      "title": "RouterOS Versions",
      "type": "piechart"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": { "color": { "mode": "palette-classic" }, "custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } }, "mappings": [] },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 6, "x": 18, "y": 1 },
      "id": 6,
      "options": {
        "legend": { "displayMode": "table", "placement": "right", "showLegend": true, "values": ["value"] },
        "pieType": "donut",
        "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
        "sort": "desc",
        "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "count by (board) (mikr_device_info{name=~\"$device\", site=~\"$site\"})", "legendFormat": "{{board}}", "refId": "A" }],
      "title": "Device Models",
      "type": "piechart"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "footer": { "reducers": [] }, "inspect": false },
          "mappings": [],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] }
        },
        "overrides": [
          {
            "matcher": { "id": "byName", "options": "Status" },
            "properties": [
              { "id": "mappings", "value": [{ "options": { "0": { "color": "red", "text": "Offline" }, "1": { "color": "green", "text": "Online" } }, "type": "value" }] },
              { "id": "custom.cellOptions", "value": { "type": "color-text" } }
            ]
          },
          {
            "matcher": { "id": "byName", "options": "CPU %" },
            "properties": [
              { "id": "unit", "value": "percent" },
              { "id": "thresholds", "value": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "yellow", "value": 70 }, { "color": "red", "value": 90 }] } },
              { "id": "custom.cellOptions", "value": { "type": "color-text" } }
            ]
          },
          {
            "matcher": { "id": "byName", "options": "RAM %" },
            "properties": [
              { "id": "unit", "value": "percent" },
              { "id": "thresholds", "value": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "yellow", "value": 70 }, { "color": "red", "value": 90 }] } },
              { "id": "custom.cellOptions", "value": { "type": "color-text" } }
            ]
          },
          {
            "matcher": { "id": "byName", "options": "Uptime" },
            "properties": [{ "id": "unit", "value": "dtdurations" }]
          },
          {
            "matcher": { "id": "byName", "options": "Temp" },
            "properties": [
              { "id": "unit", "value": "celsius" },
              { "id": "thresholds", "value": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "yellow", "value": 60 }, { "color": "red", "value": 75 }] } },
              { "id": "custom.cellOptions", "value": { "type": "color-text" } }
            ]
          }
        ]
      },
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 5 },
      "id": 7,
      "options": {
        "cellHeight": "sm", "showHeader": true,
        "sortBy": [{ "desc": false, "displayName": "Device" }]
      },
      "pluginVersion": "12.4.2",
      "targets": [
        { "expr": "mikr_device_up{name=~\"$device\", site=~\"$site\"}", "format": "table", "instant": true, "legendFormat": "", "refId": "A" },
        { "expr": "mikr_device_cpu_percent{name=~\"$device\", site=~\"$site\"}", "format": "table", "instant": true, "legendFormat": "", "refId": "B" },
        { "expr": "mikr_device_memory_percent{name=~\"$device\", site=~\"$site\"}", "format": "table", "instant": true, "legendFormat": "", "refId": "C" },
        { "expr": "mikr_device_uptime_seconds{name=~\"$device\", site=~\"$site\"}", "format": "table", "instant": true, "legendFormat": "", "refId": "D" },
        { "expr": "mikr_device_temperature_celsius{name=~\"$device\", site=~\"$site\"}", "format": "table", "instant": true, "legendFormat": "", "refId": "E" }
      ],
      "title": "Device Status",
      "transformations": [
        { "id": "joinByField", "options": { "byField": "name", "mode": "outer" } },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time 1": true, "Time 2": true, "Time 3": true, "Time 4": true, "Time 5": true,
              "__name__": true, "__name__ 1": true, "__name__ 2": true, "__name__ 3": true, "__name__ 4": true, "__name__ 5": true,
              "host 2": true, "host 3": true, "host 4": true, "host 5": true,
              "instance 1": true, "instance 2": true, "instance 3": true, "instance 4": true, "instance 5": true,
              "job 1": true, "job 2": true, "job 3": true, "job 4": true, "job 5": true,
              "site 2": true, "site 3": true, "site 4": true, "site 5": true
            },
            "indexByName": { "Value #A": 3, "Value #B": 4, "Value #C": 5, "Value #D": 6, "Value #E": 7, "host 1": 1, "name": 0, "site 1": 2 },
            "renameByName": { "Value #A": "Status", "Value #B": "CPU %", "Value #C": "RAM %", "Value #D": "Uptime", "Value #E": "Temp", "host 1": "Host", "name": "Device", "site 1": "Site" }
          }
        }
      ],
      "type": "table"
    },
    {
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 13 },
      "id": 8, "panels": [], "title": "CPU & Memory", "type": "row"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "showValues": false, "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } },
          "mappings": [], "max": 100, "min": 0,
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "yellow", "value": 70 }, { "color": "red", "value": 90 }] },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 14 },
      "id": 9,
      "options": {
        "legend": { "calcs": ["mean", "max", "lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true },
        "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_device_cpu_percent{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "CPU Load %",
      "type": "timeseries"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "showValues": false, "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } },
          "mappings": [], "max": 100, "min": 0,
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "yellow", "value": 70 }, { "color": "red", "value": 90 }] },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 14 },
      "id": 10,
      "options": {
        "legend": { "calcs": ["mean", "max", "lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true },
        "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_device_memory_percent{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "Memory Usage %",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 22 },
      "id": 11, "panels": [], "title": "Health & Environment", "type": "row"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "showValues": false, "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } },
          "mappings": [], "min": 0,
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "yellow", "value": 60 }, { "color": "red", "value": 75 }] },
          "unit": "celsius"
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 8, "x": 0, "y": 23 },
      "id": 12,
      "options": {
        "legend": { "calcs": ["mean", "max", "lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true },
        "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_device_temperature_celsius{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "Temperature",
      "type": "timeseries"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "showValues": false, "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } },
          "mappings": [],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] },
          "unit": "volt"
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 8, "x": 8, "y": 23 },
      "id": 13,
      "options": {
        "legend": { "calcs": ["mean", "min", "lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true },
        "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_device_voltage_volts{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "Voltage",
      "type": "timeseries"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 2, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "showValues": false, "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } },
          "mappings": [],
          "thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": 0 }, { "color": "red", "value": 80 }] },
          "unit": "watt"
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 8, "x": 16, "y": 23 },
      "id": 14,
      "options": {
        "legend": { "calcs": ["mean", "max", "lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true },
        "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" }
      },
      "pluginVersion": "12.4.2",
      "targets": [{ "expr": "mikr_device_power_watts{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "Power Consumption",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 31 },
      "id": 15, "panels": [], "title": "Uptime & Availability", "type": "row"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "fillOpacity": 5, "lineWidth": 2, "showPoints": "never" },
          "unit": "dtdurations"
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 12, "x": 0, "y": 32 },
      "id": 16,
      "options": {
        "legend": { "calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom" },
        "tooltip": { "mode": "multi" }
      },
      "targets": [{ "expr": "mikr_device_uptime_seconds{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "Uptime",
      "type": "timeseries"
    },
    {
      "datasource": { "uid": "${datasource}" },
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": { "fillOpacity": 30, "lineWidth": 2, "showPoints": "never", "stacking": { "mode": "none" } },
          "mappings": [{ "options": { "0": { "text": "Offline" }, "1": { "text": "Online" } }, "type": "value" }],
          "max": 1, "min": 0
        },
        "overrides": []
      },
      "gridPos": { "h": 8, "w": 12, "x": 12, "y": 32 },
      "id": 17,
      "options": {
        "legend": { "calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom" },
        "tooltip": { "mode": "multi" }
      },
      "targets": [{ "expr": "mikr_device_up{name=~\"$device\", site=~\"$site\"}", "legendFormat": "{{name}}", "refId": "A" }],
      "title": "Device Availability",
      "type": "timeseries"
    }
  ],
  "preload": false,
  "refresh": "1m",
  "schemaVersion": 42,
  "tags": ["mikrotik", "mikr", "network"],
  "templating": {
    "list": [
      {
        "current": {},
        "name": "datasource",
        "options": [],
        "query": "prometheus",
        "refresh": 1,
        "type": "datasource"
      },
      {
        "allValue": ".*",
        "current": { "text": "All", "value": "$__all" },
        "datasource": { "uid": "${datasource}" },
        "includeAll": true, "multi": true, "name": "site", "options": [],
        "query": "label_values(mikr_device_up, site)",
        "refresh": 2, "regexApplyTo": "value", "sort": 1, "type": "query"
      },
      {
        "allValue": ".*",
        "current": { "text": "All", "value": "$__all" },
        "datasource": { "uid": "${datasource}" },
        "includeAll": true, "multi": true, "name": "device", "options": [],
        "query": "label_values(mikr_device_up{site=~\"$site\"}, name)",
        "refresh": 2, "regexApplyTo": "value", "sort": 1, "type": "query"
      }
    ]
  },
  "time": { "from": "now-24h", "to": "now" },
  "timepicker": {},
  "timezone": "browser",
  "title": "MikroTik Manager — Fleet Overview",
  "uid": "mikr-fleet",
  "version": 1,
  "weekStart": ""
}
