Grafana dashboard: ShiftMon Crowdsec
Description: Display logs shipped from the crowdsec agent via telegraf to grafana loki

shows where attacks are coming from, which ASNs are attacking, which scenarios are being triggered, and a log view. This dashboard and collector is included in ShiftMon which can be found below 

https://gitlab.com/shiftsystems/shift-rmm

{
  "__inputs": [
    {
      "name": "DS_SHIFT-LOGS",
      "label": "shift-logs",
      "description": "",
      "type": "datasource",
      "pluginId": "loki",
      "pluginName": "Loki"
    }
  ],
  "__elements": [],
  "__requires": [
    {
      "type": "panel",
      "id": "bargauge",
      "name": "Bar gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "8.4.5"
    },
    {
      "type": "panel",
      "id": "grafana-worldmap-panel",
      "name": "Worldmap Panel",
      "version": "0.3.2"
    },
    {
      "type": "datasource",
      "id": "loki",
      "name": "Loki",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "piechart",
      "name": "Pie chart",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1649130998735,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "circleMaxSize": 30,
      "circleMinSize": 2,
      "colors": [
        "rgba(245, 54, 54, 0.9)",
        "rgba(237, 129, 40, 0.89)",
        "rgba(50, 172, 45, 0.97)"
      ],
      "datasource": {
        "type": "loki",
        "uid": "${DS_SHIFT-LOGS}"
      },
      "decimals": 0,
      "esMetric": "Count",
      "gridPos": {
        "h": 16,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "hideEmpty": false,
      "hideZero": false,
      "id": 2,
      "initialZoom": "2.1",
      "locationData": "countries",
      "mapCenter": "(0°, 0°)",
      "mapCenterLatitude": 0,
      "mapCenterLongitude": 0,
      "maxDataPoints": 1,
      "mouseWheelZoom": false,
      "pluginVersion": "8.4.3-54429",
      "showLegend": true,
      "stickyLabels": false,
      "tableQueryOptions": {
        "geohashField": "geohash",
        "latitudeField": "latitude",
        "longitudeField": "longitude",
        "metricField": "metric",
        "queryType": "geohash"
      },
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_SHIFT-LOGS}"
          },
          "expr": "sum(count_over_time({path=~`.*crowdsec.log`} | logfmt | ban_length=\"4h\" [$__interval])) by (country_code)",
          "legendFormat": "{{country_code}}",
          "refId": "A"
        }
      ],
      "thresholds": "0,10",
      "title": "Attack World Map",
      "transformations": [],
      "type": "grafana-worldmap-panel",
      "unitPlural": "",
      "unitSingle": "",
      "valueName": "total"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_SHIFT-LOGS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            }
          },
          "mappings": []
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "id": 3,
      "maxDataPoints": 1,
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "right",
          "values": [
            "percent"
          ]
        },
        "pieType": "donut",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "8.4.3-54429",
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_SHIFT-LOGS}"
          },
          "expr": "sum(count_over_time({path=~`.*crowdsec.log`} | logfmt | ban_length=\"4h\" [$__interval])) by (behavior)",
          "legendFormat": "{{behavior}}",
          "refId": "A"
        }
      ],
      "title": "Behaviors",
      "transformations": [],
      "type": "piechart"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_SHIFT-LOGS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 12,
        "y": 10
      },
      "id": 6,
      "maxDataPoints": 1,
      "options": {
        "displayMode": "lcd",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showUnfilled": true
      },
      "pluginVersion": "8.4.5",
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_SHIFT-LOGS}"
          },
          "expr": "sum(count_over_time({path=~`.*crowdsec.log`} | logfmt | ban_length=\"4h\" [$__interval])) by (asn) > 5",
          "legendFormat": "{{asn}}",
          "refId": "A"
        }
      ],
      "title": "Top ISPs",
      "transformations": [],
      "type": "bargauge"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_SHIFT-LOGS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 11,
        "w": 24,
        "x": 0,
        "y": 16
      },
      "id": 5,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "frameIndex": 2,
        "showHeader": true
      },
      "pluginVersion": "8.4.5",
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_SHIFT-LOGS}"
          },
          "expr": "{path=~`.*crowdsec.log`} | logfmt | ban_length=\"4h\"",
          "refId": "A"
        }
      ],
      "title": "Ban Log",
      "transformations": [
        {
          "id": "labelsToFields",
          "options": {
            "keepLabels": [
              "asn",
              "ip",
              "behavior",
              "country_code",
              "host"
            ]
          }
        },
        {
          "id": "merge",
          "options": {}
        },
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "id": true,
              "line": true,
              "traceID": true,
              "tsNs": true
            },
            "indexByName": {
              "asn": 5,
              "behavior": 3,
              "country_code": 4,
              "host": 1,
              "id": 7,
              "ip": 2,
              "line": 6,
              "traceID": 9,
              "ts": 0,
              "tsNs": 8
            },
            "renameByName": {}
          }
        }
      ],
      "type": "table"
    }
  ],
  "schemaVersion": 35,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "current": {},
        "datasource": {
          "type": "loki",
          "uid": "${DS_SHIFT-LOGS}"
        },
        "definition": "label_values({path=\"/var/log/crowdsec.log\"},host)",
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "host",
        "options": [],
        "query": "label_values({path=\"/var/log/crowdsec.log\"},host)",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false,
          "text": "shift-logs",
          "value": "shift-logs"
        },
        "hide": 0,
        "includeAll": false,
        "multi": false,
        "name": "logs",
        "options": [],
        "query": "loki",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "type": "datasource"
      }
    ]
  },
  "time": {
    "from": "now-12h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "ShiftMon Crowdsec",
  "uid": "j4KEK3L7k",
  "version": 2,
  "weekStart": "",
  "gnetId": 16051,
  "description": "Display logs shipped from the crowdsec agent via telegraf to grafana loki"
}