Grafana dashboard: Mikrotik Loki Logs
Description: Mikrotik Loki Logs

![License](https://img.shields.io/badge/mikrotik-routeros-orange)
![Language](https://img.shields.io/badge/docker-%230db7ed.svg)
![License](https://img.shields.io/badge/License-GNU%20GPL-blue.svg)

This dashboard is a part of [MKTXP-Stack](https://github.com/akpw/mktxp-stack), a dockerized syslog-ng / promtail / Loki stack to receive & process logs from multiple Mikrotik RouterOS devices in a centralized location

{
  "__inputs": [
    {
      "name": "DS_LOKI",
      "label": "Loki",
      "description": "",
      "type": "datasource",
      "pluginId": "loki",
      "pluginName": "Loki"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "9.3.2"
    },
    {
      "type": "panel",
      "id": "logs",
      "name": "Logs",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "loki",
      "name": "Loki",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "description": "Mikrotik Loki Logs",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "gnetId": 17139,
  "graphTooltip": 0,
  "id": null,
  "links": [
    {
      "asDropdown": false,
      "icon": "external link",
      "includeVars": false,
      "keepTime": false,
      "tags": [
        "mikrotik",
        "mktxp"
      ],
      "targetBlank": false,
      "title": "MKTXP Exporter",
      "tooltip": "",
      "type": "dashboards",
      "url": ""
    },
    {
      "asDropdown": true,
      "icon": "external link",
      "keepTime": false,
      "tags": [
        "system"
      ],
      "title": "System Overview",
      "type": "dashboards"
    }
  ],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "semi-dark-orange",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 0,
        "y": 0
      },
      "id": 4,
      "interval": "$smooth",
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "center",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "sum"
          ],
          "fields": "",
          "values": false
        },
        "text": {},
        "textMode": "auto"
      },
      "pluginVersion": "9.3.2",
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_LOKI}"
          },
          "editorMode": "code",
          "expr": "count_over_time({job=\"syslog\", routerboard=\"$routerboard\"} [$__interval] |~\"(?i)$topics\" |~\"(?i)$searchable_pattern\" !~\"(?i)$exclude\")",
          "legendFormat": "{{host}}",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Log Counts By Topic",
      "transformations": [],
      "type": "stat"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 30,
            "gradientMode": "opacity",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": true,
            "stacking": {
              "group": "A",
              "mode": "normal"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 15,
        "x": 9,
        "y": 0
      },
      "id": 3,
      "interval": "$smooth",
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "sum"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "none",
          "sort": "none"
        }
      },
      "pluginVersion": "8.1.2",
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_LOKI}"
          },
          "editorMode": "code",
          "expr": "count_over_time({job=\"syslog\", routerboard=\"$routerboard\"} [$__interval] |regexp \"(?P<prefix>\\\\w+)\\\\: \" |~\"(?i)$topics\" |~\"(?i)$searchable_pattern\" !~\"(?i)$exclude\")",
          "legendFormat": "{{prefix}}",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Log Counts By Topic Over Time",
      "transformations": [],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "description": "",
      "gridPos": {
        "h": 23,
        "w": 24,
        "x": 0,
        "y": 7
      },
      "id": 5,
      "options": {
        "dedupStrategy": "none",
        "enableLogDetails": true,
        "prettifyLogMessage": false,
        "showCommonLabels": false,
        "showLabels": false,
        "showTime": false,
        "sortOrder": "Descending",
        "wrapLogMessage": false
      },
      "pluginVersion": "7.3.6",
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_LOKI}"
          },
          "editorMode": "code",
          "expr": "{job=\"syslog\", routerboard=\"$routerboard\"} |~\"(?i)$topics\" |~\"(?i)$searchable_pattern\" !~\"(?i)$exclude\"",
          "legendFormat": "",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Logs Lines By Topic",
      "type": "logs"
    }
  ],
  "refresh": "5s",
  "schemaVersion": 37,
  "style": "dark",
  "tags": [
    "mikrotik",
    "loki"
  ],
  "templating": {
    "list": [
      {
        "current": {},
        "datasource": {
          "type": "loki",
          "uid": "${DS_LOKI}"
        },
        "definition": "",
        "hide": 0,
        "includeAll": false,
        "label": "Routerboard",
        "multi": false,
        "name": "routerboard",
        "options": [],
        "query": {
          "label": "routerboard",
          "refId": "LokiVariableQueryEditor-VariableQuery",
          "stream": "",
          "type": 1
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "hide": 0,
        "includeAll": true,
        "label": "Topics",
        "multi": true,
        "name": "topics",
        "options": [
          {
            "selected": true,
            "text": "All",
            "value": "$__all"
          },
          {
            "selected": false,
            "text": "account",
            "value": "account"
          },
          {
            "selected": false,
            "text": "caps",
            "value": "caps"
          },
          {
            "selected": false,
            "text": "critical",
            "value": "critical"
          },
          {
            "selected": false,
            "text": "error",
            "value": "error"
          },
          {
            "selected": false,
            "text": "firewall",
            "value": "firewall"
          },
          {
            "selected": false,
            "text": "info",
            "value": "info"
          },
          {
            "selected": false,
            "text": "warning",
            "value": "warning"
          },
          {
            "selected": false,
            "text": "wireless",
            "value": "wireless"
          },
          {
            "selected": false,
            "text": "dns",
            "value": "dns"
          },
          {
            "selected": false,
            "text": "health",
            "value": "health"
          },
          {
            "selected": false,
            "text": "dhcp",
            "value": "dhcp"
          },
          {
            "selected": false,
            "text": "interface",
            "value": "interface"
          },
          {
            "selected": false,
            "text": "ipsec",
            "value": "ipsec"
          },
          {
            "selected": false,
            "text": "l2tp",
            "value": "l2tp"
          },
          {
            "selected": false,
            "text": "ppp",
            "value": "ppp"
          },
          {
            "selected": false,
            "text": "raw",
            "value": "raw"
          },
          {
            "selected": false,
            "text": "ssh",
            "value": "ssh"
          },
          {
            "selected": false,
            "text": "system",
            "value": "system"
          },
          {
            "selected": false,
            "text": "ups",
            "value": "ups"
          }
        ],
        "query": "account,caps,critical,error,firewall,info,warning,wireless,dns,health,dhcp,interface,ipsec,l2tp,ppp,raw,ssh,system,ups",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "current": {
          "selected": true,
          "text": "",
          "value": ""
        },
        "description": "Search (case insensitive)",
        "hide": 0,
        "label": "Search",
        "name": "searchable_pattern",
        "options": [
          {
            "selected": true,
            "text": "",
            "value": ""
          }
        ],
        "query": "",
        "skipUrlSync": false,
        "type": "textbox"
      },
      {
        "current": {
          "selected": false,
          "text": "None",
          "value": "None"
        },
        "description": "Exclude pattern (case-insensitive, None includes everything)",
        "hide": 0,
        "includeAll": false,
        "label": "Exclude",
        "multi": false,
        "name": "exclude",
        "options": [
          {
            "selected": true,
            "text": "None",
            "value": "None"
          }
        ],
        "query": "None,",
        "queryValue": "None",
        "skipUrlSync": false,
        "type": "custom"
      },
      {
        "current": {
          "selected": false,
          "text": "5m",
          "value": "5m"
        },
        "hide": 0,
        "includeAll": false,
        "label": "Smooth",
        "multi": false,
        "name": "smooth",
        "options": [
          {
            "selected": false,
            "text": "30s",
            "value": "30s"
          },
          {
            "selected": false,
            "text": "1m",
            "value": "1m"
          },
          {
            "selected": false,
            "text": "2m",
            "value": "2m"
          },
          {
            "selected": true,
            "text": "5m",
            "value": "5m"
          },
          {
            "selected": false,
            "text": "10m",
            "value": "10m"
          },
          {
            "selected": false,
            "text": "15m",
            "value": "15m"
          },
          {
            "selected": false,
            "text": "30m",
            "value": "30m"
          },
          {
            "selected": false,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": false,
            "text": "2h",
            "value": "2h"
          }
        ],
        "query": "30s,1m,2m,5m,10m,15m,30m,1h,2h",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-12h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Mikrotik Loki Logs",
  "uid": "awslix6doiakp-mkt-loki",
  "version": 1,
  "weekStart": ""
}