{
  "uid": "incus-logs-explorer",
  "title": "Logs Explorer",
  "description": "Log volume over time, full log stream with search, error and warning rates by systemd unit. Datasource: Loki.",
  "tags": [
    "incus",
    "logs",
    "loki"
  ],
  "timezone": "browser",
  "schemaVersion": 39,
  "refresh": "30s",
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "fiscalYearStartMonth": 0,
  "liveNow": false,
  "editable": true,
  "graphTooltip": 1,
  "links": [
    {
      "asDropdown": true,
      "icon": "external link",
      "includeVars": true,
      "keepTime": true,
      "tags": [
        "incus"
      ],
      "targetBlank": false,
      "title": "Incus Dashboards",
      "tooltip": "Navigate to other Incus dashboards",
      "type": "dashboards"
    },
    {
      "asDropdown": false,
      "icon": "doc",
      "includeVars": false,
      "keepTime": true,
      "targetBlank": false,
      "title": "Logs Drilldown",
      "tooltip": "Interactive log exploration with automatic field discovery and pattern detection",
      "type": "link",
      "url": "/a/grafana-lokiexplore-app/explore"
    }
  ],
  "templating": {
    "list": [
      {
        "type": "query",
        "datasource": {
          "type": "loki",
          "uid": "${DS_LOKI}"
        },
        "query": "label_values(job)",
        "includeAll": true,
        "multi": true,
        "name": "job",
        "label": "Job",
        "refresh": 2,
        "sort": 1,
        "allValue": ".+"
      },
      {
        "type": "query",
        "datasource": {
          "type": "loki",
          "uid": "${DS_LOKI}"
        },
        "query": "label_values(host)",
        "includeAll": true,
        "multi": true,
        "name": "host",
        "label": "Host",
        "refresh": 2,
        "sort": 1,
        "allValue": ".+"
      },
      {
        "type": "query",
        "datasource": {
          "type": "loki",
          "uid": "${DS_LOKI}"
        },
        "query": "label_values(unit)",
        "includeAll": true,
        "multi": true,
        "name": "unit",
        "label": "Unit",
        "refresh": 2,
        "sort": 1,
        "allValue": ".+"
      },
      {
        "type": "textbox",
        "name": "search",
        "label": "Search",
        "current": {
          "text": "",
          "value": ""
        }
      }
    ]
  },
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "panels": [
    {
      "type": "row",
      "title": "Log Volume",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 1,
      "panels": []
    },
    {
      "type": "timeseries",
      "title": "Log Volume Over Time",
      "description": "Total log line count over time, broken down by job. Shows the rate at which logs are being generated across all selected sources.",
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 1
      },
      "id": 2,
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "targets": [
        {
          "expr": "sum by (job) (count_over_time({job=~\"$job\", host=~\"$host\"} [$__auto]))",
          "legendFormat": "{{job}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "bars",
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "fillOpacity": 80,
            "gradientMode": "none",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "normal",
              "group": "A"
            },
            "axisPlacement": "auto",
            "axisLabel": "",
            "scaleDistribution": {
              "type": "linear"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "unit": "short",
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        },
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "calcs": [
            "sum",
            "max",
            "lastNotNull"
          ]
        }
      }
    },
    {
      "type": "row",
      "title": "Log Stream",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 7
      },
      "id": 3,
      "panels": []
    },
    {
      "type": "logs",
      "title": "Logs",
      "description": "Live log stream filtered by job, host, unit, and free-text search. Displays timestamps, labels, and full log messages with expand-on-click detail view.",
      "gridPos": {
        "h": 16,
        "w": 24,
        "x": 0,
        "y": 8
      },
      "id": 4,
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "targets": [
        {
          "expr": "{job=~\"$job\", host=~\"$host\"} |= \"$search\"",
          "refId": "A"
        }
      ],
      "options": {
        "showTime": true,
        "showLabels": true,
        "showCommonLabels": false,
        "wrapLogMessage": true,
        "prettifyLogMessage": false,
        "enableLogDetails": true,
        "sortOrder": "Descending",
        "dedupStrategy": "none"
      }
    },
    {
      "type": "row",
      "title": "Error & Warning Rates",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 24
      },
      "id": 5,
      "panels": []
    },
    {
      "type": "timeseries",
      "title": "Error Rate by Unit",
      "description": "Rate of log lines matching error, fail, or fatal (case-insensitive) over time, grouped by systemd unit. Spikes indicate services experiencing failures.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 25
      },
      "id": 6,
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "targets": [
        {
          "expr": "sum by (unit) (count_over_time({job=~\"$job\", host=~\"$host\"} |~ \"(?i)error|fail|fatal\" [$__auto]))",
          "legendFormat": "{{unit}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "fillOpacity": 15,
            "gradientMode": "none",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "axisLabel": "",
            "scaleDistribution": {
              "type": "linear"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "unit": "short",
          "color": {
            "mode": "fixed",
            "fixedColor": "red"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        },
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "calcs": [
            "sum",
            "max",
            "lastNotNull"
          ]
        }
      }
    },
    {
      "type": "timeseries",
      "title": "Warning Rate by Unit",
      "description": "Rate of log lines matching warn (case-insensitive) over time, grouped by systemd unit. Helps identify services generating warnings that may precede errors.",
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 25
      },
      "id": 7,
      "datasource": {
        "type": "loki",
        "uid": "${DS_LOKI}"
      },
      "targets": [
        {
          "expr": "sum by (unit) (count_over_time({job=~\"$job\", host=~\"$host\"} |~ \"(?i)warn\" [$__auto]))",
          "legendFormat": "{{unit}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 1,
            "fillOpacity": 15,
            "gradientMode": "none",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "axisLabel": "",
            "scaleDistribution": {
              "type": "linear"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "unit": "short",
          "color": {
            "mode": "fixed",
            "fixedColor": "yellow"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "yellow",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        },
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "calcs": [
            "sum",
            "max",
            "lastNotNull"
          ]
        }
      }
    }
  ]
}
