Grafana dashboard: Kubernetes Logs from Loki
Description: Basic dashboard for Kubernetes Logs from Loki. You will need to make your own customizations.

This is a modified version from the dashboard promoted in the Grafana blog (see [here](https://grafana.com/blog/2020/04/08/loki-quick-tip-how-to-create-a-grafana-dashboard-for-searching-logs-using-loki-and-prometheus/)). The original didn't work out of the box for me and was missing some features.

**Features**

- Allows to filter by namespaces & pods
- Allows to search for strings via regex
- Auto-refresh is enabled by default

**Notes**
- If you want to see the context of a log then click on "Explore" in the log panel
- You can search for any terms, not only the predefined ones

You will probably need to do your own customizations.

{
  "__inputs": [
    {
      "name": "DS_GRAFANACLOUD-SS3RG3-LOGS",
      "label": "grafanacloud-ss3rg3-logs",
      "description": "",
      "type": "datasource",
      "pluginId": "loki",
      "pluginName": "Loki"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "9.5.0-cloud.2.f143d34"
    },
    {
      "type": "panel",
      "id": "logs",
      "name": "Logs",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "loki",
      "name": "Loki",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "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": "Basic dashboard for Kubernetes Logs from Loki. You will need to make your own customizations.",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "liveNow": true,
  "panels": [
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_GRAFANACLOUD-SS3RG3-LOGS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 5,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_GRAFANACLOUD-SS3RG3-LOGS}"
          },
          "editorMode": "code",
          "expr": "sum(count_over_time({namespace=~\"$namespace\", pod=~\"$pod\"} |~ \"$search\"[$__interval]))",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "loki",
        "uid": "${DS_GRAFANACLOUD-SS3RG3-LOGS}"
      },
      "gridPos": {
        "h": 16,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "id": 3,
      "options": {
        "dedupStrategy": "exact",
        "enableLogDetails": true,
        "prettifyLogMessage": false,
        "showCommonLabels": false,
        "showLabels": true,
        "showTime": true,
        "sortOrder": "Descending",
        "wrapLogMessage": true
      },
      "targets": [
        {
          "datasource": {
            "type": "loki",
            "uid": "${DS_GRAFANACLOUD-SS3RG3-LOGS}"
          },
          "editorMode": "code",
          "expr": "{namespace=~\"$namespace\", pod=~\"$pod\"} |~ \"(?i)$search\"",
          "queryType": "range",
          "refId": "A"
        }
      ],
      "title": "Logs Panel",
      "type": "logs"
    }
  ],
  "refresh": "10s",
  "schemaVersion": 38,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": [
      {
        "allValue": ".+",
        "current": {},
        "datasource": {
          "type": "loki",
          "uid": "${DS_GRAFANACLOUD-SS3RG3-LOGS}"
        },
        "definition": "",
        "hide": 0,
        "includeAll": true,
        "label": "Namespace",
        "multi": false,
        "name": "namespace",
        "options": [],
        "query": {
          "label": "namespace",
          "refId": "LokiVariableQueryEditor-VariableQuery",
          "stream": "",
          "type": 1
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "allValue": ".+",
        "current": {},
        "datasource": {
          "type": "loki",
          "uid": "${DS_GRAFANACLOUD-SS3RG3-LOGS}"
        },
        "definition": "",
        "hide": 0,
        "includeAll": true,
        "label": "Pod",
        "multi": false,
        "name": "pod",
        "options": [],
        "query": {
          "label": "pod",
          "refId": "LokiVariableQueryEditor-VariableQuery",
          "stream": "",
          "type": 1
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": true,
          "text": "error|fatal",
          "value": "error|fatal"
        },
        "hide": 0,
        "includeAll": false,
        "label": "Search Term",
        "multi": false,
        "name": "search",
        "options": [
          {
            "selected": true,
            "text": "error|fatal",
            "value": "error|fatal"
          },
          {
            "selected": false,
            "text": "warn|error|fatal",
            "value": "warn|error|fatal"
          },
          {
            "selected": false,
            "text": "fatal",
            "value": "fatal"
          },
          {
            "selected": false,
            "text": "error",
            "value": "error"
          },
          {
            "selected": false,
            "text": "warn",
            "value": "warn"
          },
          {
            "selected": false,
            "text": "info",
            "value": "info"
          },
          {
            "selected": false,
            "text": ".+",
            "value": ".+"
          }
        ],
        "query": "error|fatal,warn|error|fatal,fatal,error,warn,info,.+",
        "queryValue": "",
        "skipUrlSync": false,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Kubernetes Logs from Loki",
  "uid": "ae3ec2c4-1c19-4450-9403-226270fe0c4f",
  "version": 8,
  "weekStart": "",
  "gnetId": 18494
}