Grafana dashboard: Logging Dashboard via Loki
Description: Universal and flexible dashboard for logging

Main dashboard for logs

{
  "__inputs": [
    {
      "name": "DS_LOKI",
      "label": "Loki",
      "description": "",
      "type": "datasource",
      "pluginId": "loki",
      "pluginName": "Loki"
    }
  ],
  "__requires": [
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "7.0.4"
    },
    {
      "type": "panel",
      "id": "grafana-piechart-panel",
      "name": "Pie Chart",
      "version": "1.5.0"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "graphite",
      "name": "Graphite",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "logs",
      "name": "Logs",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "loki",
      "name": "Loki",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "text",
      "name": "Text",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "Universal and flexible dashboard for logging",
  "editable": true,
  "gnetId": 18444,
  "graphTooltip": 0,
  "id": null,
  "iteration": 1594222083341,
  "links": [],
  "panels": [
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorPostfix": true,
      "colorValue": true,
      "colors": [
        "rgb(31, 255, 7)",
        "rgb(31, 255, 7)",
        "rgb(31, 255, 7)"
      ],
      "datasource": "${DS_LOKI}",
      "description": "Total  Count of log lines in the specified time range",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "format": "short",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 11,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "$$hashKey": "object:65",
          "name": "value to text",
          "value": 1
        },
        {
          "$$hashKey": "object:66",
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "pluginVersion": "6.4.3",
      "postfix": " lines",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgb(0, 82, 0)",
        "full": false,
        "lineColor": "rgb(31, 255, 7)",
        "show": true,
        "ymax": null,
        "ymin": null
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", stream=~\"$stream\", pod_name=~\"$pod_name\"})[$__interval]))",
          "hide": false,
          "refId": "A"
        }
      ],
      "thresholds": "10,50",
      "timeFrom": null,
      "timeShift": null,
      "title": "Total  Count of logs",
      "type": "singlestat",
      "valueFontSize": "70%",
      "valueMaps": [
        {
          "$$hashKey": "object:68",
          "op": "=",
          "text": "0",
          "value": "null"
        }
      ],
      "valueName": "total"
    },
    {
      "cacheTimeout": null,
      "colorBackground": false,
      "colorPostfix": true,
      "colorPrefix": false,
      "colorValue": true,
      "colors": [
        "rgb(222, 15, 43)",
        "rgb(222, 15, 43)",
        "rgb(222, 15, 43)"
      ],
      "datasource": "${DS_LOKI}",
      "description": "Total Count: of $searchable_pattern in the specified time range",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "format": "short",
      "gauge": {
        "maxValue": 100,
        "minValue": 0,
        "show": false,
        "thresholdLabels": false,
        "thresholdMarkers": true
      },
      "gridPos": {
        "h": 3,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "id": 6,
      "interval": null,
      "links": [],
      "mappingType": 1,
      "mappingTypes": [
        {
          "$$hashKey": "object:1630",
          "name": "value to text",
          "value": 1
        },
        {
          "$$hashKey": "object:1631",
          "name": "range to text",
          "value": 2
        }
      ],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "nullText": null,
      "pluginVersion": "6.4.3",
      "postfix": " \"$searchable_pattern\"",
      "postfixFontSize": "50%",
      "prefix": "",
      "prefixFontSize": "50%",
      "rangeMaps": [
        {
          "from": "null",
          "text": "N/A",
          "to": "null"
        }
      ],
      "sparkline": {
        "fillColor": "rgb(105, 34, 43)",
        "full": false,
        "lineColor": "#C4162A",
        "show": true,
        "ymax": null,
        "ymin": null
      },
      "tableColumn": "",
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", stream=~\"$stream\", pod_name=~\"$pod_name\"} |~ \"(?i)$searchable_pattern\")[$__interval]))",
          "hide": false,
          "refId": "A"
        }
      ],
      "thresholds": "10,50",
      "timeFrom": null,
      "timeShift": null,
      "title": "Total Count: of $searchable_pattern",
      "type": "singlestat",
      "valueFontSize": "70%",
      "valueMaps": [
        {
          "$$hashKey": "object:1633",
          "op": "=",
          "text": "0",
          "value": "null"
        }
      ],
      "valueName": "total"
    },
    {
      "datasource": "${DS_LOKI}",
      "description": "Live logs is a like 'tail -f' in a real time",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 3
      },
      "id": 2,
      "options": {
        "showLabels": true,
        "showTime": false,
        "sortOrder": "Descending",
        "wrapLogMessage": false
      },
      "targets": [
        {
          "expr": "{container_name=\"$container_name\", pod_name=~\"$pod_name\", stream=~\"$stream\"} |~ \"(?i)$searchable_pattern\" ",
          "hide": false,
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Live logs",
      "type": "logs"
    },
    {
      "content": "",
      "datasource": "${DS_NY-ALERTING2}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "gridPos": {
        "h": 2,
        "w": 24,
        "x": 0,
        "y": 12
      },
      "id": 15,
      "mode": "html",
      "targets": [
        {
          "refId": "A",
          "target": ""
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "",
      "type": "text"
    },
    {
      "aliasColors": {
        "stderr": "#C4162A",
        "stdout": "#37872D"
      },
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Others",
        "threshold": 0
      },
      "datasource": "${DS_LOKI}",
      "decimals": null,
      "fieldConfig": {
        "defaults": {
          "custom": {},
          "mappings": [
            {
              "id": 0,
              "op": "=",
              "text": "0",
              "type": 1,
              "value": "null"
            }
          ],
          "nullValueMode": "connected",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#299c46",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": 10
              },
              {
                "color": "#C4162A",
                "value": 50
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "fontSize": "80%",
      "format": "short",
      "gridPos": {
        "h": 7,
        "w": 7,
        "x": 0,
        "y": 14
      },
      "id": 19,
      "interval": null,
      "legend": {
        "header": "Total Count",
        "percentage": true,
        "percentageDecimals": 2,
        "show": true,
        "sort": "total",
        "sortDesc": true,
        "values": true
      },
      "legendType": "Under graph",
      "links": [],
      "maxDataPoints": 100,
      "nullPointMode": "connected",
      "pieType": "pie",
      "pluginVersion": "7.0.4",
      "strokeWidth": "1.5",
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", pod_name=~\"$pod_name\"})[$__interval])) by (stream)",
          "hide": false,
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Total count of stderr / stdout pie",
      "type": "grafana-piechart-panel",
      "valueName": "total"
    },
    {
      "aliasColors": {},
      "breakPoint": "50%",
      "cacheTimeout": null,
      "combine": {
        "label": "Others",
        "threshold": 0
      },
      "datasource": "${DS_LOKI}",
      "decimals": 0,
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fontSize": "80%",
      "format": "short",
      "gridPos": {
        "h": 7,
        "w": 12,
        "x": 7,
        "y": 14
      },
      "id": 20,
      "interval": "1m",
      "legend": {
        "header": "total count",
        "percentage": true,
        "show": true,
        "sort": "total",
        "sortDesc": true,
        "values": true
      },
      "legendType": "Right side",
      "links": [],
      "maxDataPoints": "",
      "nullPointMode": "connected",
      "pieType": "donut",
      "pluginVersion": "6.4.3",
      "strokeWidth": "0.4",
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", pod_name=~\"$pod_name\", stream=~\"$stream\"} |~ \"(?i)$searchable_pattern\")[$__interval])) by (pod_name)",
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "Matched word: \"$searchable_pattern\" donut",
      "type": "grafana-piechart-panel",
      "valueName": "total"
    },
    {
      "cacheTimeout": null,
      "datasource": "${DS_LOKI}",
      "fieldConfig": {
        "defaults": {
          "custom": {},
          "mappings": [
            {
              "id": 0,
              "op": "=",
              "text": "0",
              "type": 1,
              "value": "null"
            }
          ],
          "max": 100,
          "min": 0,
          "noValue": "0",
          "nullValueMode": "connected",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#299c46",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": 10
              },
              {
                "color": "#C4162A",
                "value": 50
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 7,
        "w": 5,
        "x": 19,
        "y": 14
      },
      "id": 9,
      "interval": null,
      "links": [],
      "maxDataPoints": 100,
      "options": {
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "mean"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": false
      },
      "pluginVersion": "7.0.4",
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", stream=~\"$stream\", pod_name=~\"$pod_name\"} |~ \"(?i)$searchable_pattern\")[$__interval])) * 100 / sum(count_over_time(({container_name=\"$container_name\", stream=~\"$stream\", pod_name=~\"$pod_name\"})[$__interval]))",
          "hide": false,
          "refId": "A"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "\"$searchable_pattern\" Percentage for specified time",
      "type": "gauge"
    },
    {
      "aliasColors": {},
      "bars": true,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_LOKI}",
      "decimals": 0,
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 1,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 0,
        "y": 21
      },
      "hiddenSeries": false,
      "id": 18,
      "interval": "1m",
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": true,
        "hideEmpty": false,
        "hideZero": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "sort": "current",
        "sortDesc": true,
        "total": false,
        "values": true
      },
      "lines": false,
      "linewidth": 3,
      "links": [],
      "maxDataPoints": "",
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pluginVersion": "6.4.3",
      "pointradius": 2,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", pod_name=~\"$pod_name\", stream=~\"$stream\"} |~ \"(?i)$searchable_pattern\")[$__interval])) by (pod_name)",
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Matched word: \"$searchable_pattern\" historical",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:425",
          "decimals": 0,
          "format": "short",
          "label": "Count",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:426",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": false
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_LOKI}",
      "fieldConfig": {
        "defaults": {
          "custom": {}
        },
        "overrides": []
      },
      "fill": 1,
      "fillGradient": 10,
      "gridPos": {
        "h": 9,
        "w": 12,
        "x": 12,
        "y": 21
      },
      "hiddenSeries": false,
      "id": 10,
      "interval": null,
      "legend": {
        "alignAsTable": true,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "maxDataPoints": 100,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pluginVersion": "6.4.3",
      "pointradius": 0.5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rate(({container_name=\"$container_name\", stream=~\"$stream\", pod_name=~\"$pod_name\"} |~ \"(?i)$searchable_pattern\")[30s])) by (pod_name)",
          "hide": false,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "\"$searchable_pattern\" Rate per Pod",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:2804",
          "format": "short",
          "label": null,
          "logBase": 10,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:2805",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "cacheTimeout": null,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_LOKI}",
      "fieldConfig": {
        "defaults": {
          "custom": {},
          "mappings": [
            {
              "id": 0,
              "op": "=",
              "text": "0",
              "type": 1,
              "value": "null"
            }
          ],
          "nullValueMode": "connected",
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "#299c46",
                "value": null
              },
              {
                "color": "rgba(237, 129, 40, 0.89)",
                "value": 10
              },
              {
                "color": "#C4162A",
                "value": 50
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "fill": 2,
      "fillGradient": 4,
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 30
      },
      "hiddenSeries": false,
      "id": 7,
      "interval": null,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": true,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "maxDataPoints": 100,
      "nullPointMode": "null",
      "options": {
        "dataLinks": []
      },
      "percentage": false,
      "pluginVersion": "7.0.4",
      "pointradius": 2,
      "points": true,
      "renderer": "flot",
      "seriesOverrides": [
        {
          "$$hashKey": "object:154",
          "alias": "{stream=\"stderr\"} stderr",
          "color": "#C4162A",
          "legend": false,
          "linewidth": 2
        },
        {
          "$$hashKey": "object:220",
          "alias": "{stream=\"stdout\"} stdout",
          "color": "#56A64B",
          "legend": false,
          "linewidth": 2
        }
      ],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(count_over_time(({container_name=\"$container_name\", pod_name=~\"$pod_name\"})[$__interval])) by (stream)",
          "hide": false,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "Count of stderr / stdout historical",
      "tooltip": {
        "shared": true,
        "sort": 2,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "$$hashKey": "object:188",
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "$$hashKey": "object:189",
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": "5s",
  "schemaVersion": 25,
  "style": "dark",
  "tags": [
    "Loki",
    "logging"
  ],
  "templating": {
    "list": [
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_LOKI}",
        "definition": "label_values({container_name=~\".+\"}, container_name)",
        "hide": 0,
        "includeAll": false,
        "label": "Service",
        "multi": false,
        "name": "container_name",
        "options": [],
        "query": "label_values({container_name=~\".+\"}, container_name)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_LOKI}",
        "definition": "label_values({container_name=\"$container_name\"}, pod_name)",
        "hide": 0,
        "includeAll": true,
        "label": "Pod",
        "multi": false,
        "name": "pod_name",
        "options": [],
        "query": "label_values({container_name=\"$container_name\"}, pod_name)",
        "refresh": 2,
        "regex": "$container_name.*",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "allValue": null,
        "current": {},
        "datasource": "${DS_LOKI}",
        "definition": "label_values({container_name=\"$container_name\"}, stream)",
        "hide": 0,
        "includeAll": true,
        "label": "Stream",
        "multi": false,
        "name": "stream",
        "options": [],
        "query": "label_values({container_name=\"$container_name\"}, stream)",
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "tagValuesQuery": "",
        "tags": [],
        "tagsQuery": "",
        "type": "query",
        "useTags": false
      },
      {
        "current": {
          "selected": false,
          "text": "error",
          "value": "error"
        },
        "hide": 0,
        "label": "Search (case insensitive)",
        "name": "searchable_pattern",
        "options": [
          {
            "selected": true,
            "text": "",
            "value": ""
          }
        ],
        "query": "",
        "skipUrlSync": false,
        "type": "textbox"
      }
    ]
  },
  "time": {
    "from": "now-30m",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ]
  },
  "timezone": "",
  "title": "Logging Dashboard via Loki",
  "uid": "fRIvzUZMz",
  "version": 64
}