updated monitoring stack for k3s and added kube dashboards

This commit is contained in:
rezayaghobi-dev
2026-08-16 22:26:40 +03:30
parent 4acb8b5ac1
commit d5bc686665
10 changed files with 8131 additions and 43 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,574 @@
{
"apiVersion": "dashboard.grafana.app/v2",
"kind": "Dashboard",
"metadata": {
"name": "k3s-unified-custom",
"namespace": "default",
"uid": "bdd5aead-f832-414c-ae5a-d78512b329bc",
"resourceVersion": "1786873984999019",
"generation": 1,
"creationTimestamp": "2026-08-16T09:53:04Z",
"labels": {
"grafana.app/deprecatedInternalID": "3760385721421824"
},
"annotations": {
"grafana.app/createdBy": "user:dfbtp4cn32dj4f",
"grafana.app/folder": "",
"grafana.app/saved-from-ui": "Grafana v13.1.1 (a9cee6e172)"
}
},
"spec": {
"annotations": [
{
"kind": "AnnotationQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "grafana",
"version": "v0",
"datasource": {
"name": "-- Grafana --"
},
"spec": {}
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"builtIn": true,
"legacyOptions": {
"type": "dashboard"
}
}
}
],
"cursorSync": "Off",
"editable": true,
"elements": {
"panel-1": {
"kind": "Panel",
"spec": {
"id": 1,
"title": "Running Pods",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "${DS_PROMETHEUS}"
},
"spec": {
"expr": "sum(kube_pod_status_phase{namespace=~\"$namespace\", pod=~\"$pod\", phase=\"Running\"})"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "stat",
"version": "",
"spec": {
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "fixed",
"fixedColor": "green"
}
},
"overrides": []
}
}
}
}
},
"panel-2": {
"kind": "Panel",
"spec": {
"id": 2,
"title": "Problem Pods",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "${DS_PROMETHEUS}"
},
"spec": {
"expr": "sum(kube_pod_status_phase{namespace=~\"$namespace\", pod=~\"$pod\", phase=~\"Failed|Pending|Unknown\"})"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "stat",
"version": "",
"spec": {
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "fixed",
"fixedColor": "red"
}
},
"overrides": []
}
}
}
}
},
"panel-3": {
"kind": "Panel",
"spec": {
"id": 3,
"title": "Pod CPU Usage",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "${DS_PROMETHEUS}"
},
"spec": {
"expr": "sum by (pod) (rate(container_cpu_usage_seconds_total{namespace=~\"$namespace\", pod=~\"$pod\", image!=\"\"}[$__rate_interval]))",
"legendFormat": "{{pod}}"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "timeseries",
"version": "",
"spec": {
"options": {},
"fieldConfig": {
"defaults": {},
"overrides": []
}
}
}
}
},
"panel-4": {
"kind": "Panel",
"spec": {
"id": 4,
"title": "Pod Memory Usage",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "${DS_PROMETHEUS}"
},
"spec": {
"expr": "sum by (pod) (container_memory_working_set_bytes{namespace=~\"$namespace\", pod=~\"$pod\", image!=\"\"})",
"legendFormat": "{{pod}}"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "timeseries",
"version": "",
"spec": {
"options": {},
"fieldConfig": {
"defaults": {
"unit": "bytes"
},
"overrides": []
}
}
}
}
},
"panel-5": {
"kind": "Panel",
"spec": {
"id": 5,
"title": "Live Pod Logs",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"expr": "{cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\"} |~ \"$search\""
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "logs",
"version": "",
"spec": {
"options": {
"showLabels": true,
"showTime": true,
"wrapLogMessage": true
},
"fieldConfig": {
"defaults": {},
"overrides": []
}
}
}
}
}
},
"layout": {
"kind": "RowsLayout",
"spec": {
"rows": [
{
"kind": "RowsLayoutRow",
"spec": {
"title": "K3s Cluster Status (kube-state-metrics)",
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 12,
"height": 5,
"element": {
"kind": "ElementReference",
"name": "panel-1"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 12,
"y": 0,
"width": 12,
"height": 5,
"element": {
"kind": "ElementReference",
"name": "panel-2"
}
}
}
]
}
}
}
},
{
"kind": "RowsLayoutRow",
"spec": {
"title": "K3s Compute (cAdvisor)",
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 12,
"height": 7,
"element": {
"kind": "ElementReference",
"name": "panel-3"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 12,
"y": 0,
"width": 12,
"height": 7,
"element": {
"kind": "ElementReference",
"name": "panel-4"
}
}
}
]
}
}
}
},
{
"kind": "RowsLayoutRow",
"spec": {
"title": "K3s Logs (Loki + Alloy)",
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 24,
"height": 14,
"element": {
"kind": "ElementReference",
"name": "panel-5"
}
}
}
]
}
}
}
}
]
}
},
"links": [],
"liveNow": false,
"preload": false,
"tags": [],
"timeSettings": {
"from": "now-1h",
"to": "now",
"autoRefresh": "",
"autoRefreshIntervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"hideTimepicker": false,
"fiscalYearStartMonth": 0
},
"title": "K3s Unified Application Dashboard",
"variables": [
{
"kind": "DatasourceVariable",
"spec": {
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"refresh": "never",
"regex": "",
"current": {
"text": "",
"value": ""
},
"options": [],
"multi": false,
"includeAll": false,
"label": "Prometheus Data Source",
"hide": "dontHide",
"skipUrlSync": false,
"allowCustomValue": true
}
},
{
"kind": "DatasourceVariable",
"spec": {
"name": "DS_LOKI",
"pluginId": "loki",
"refresh": "never",
"regex": "",
"current": {
"text": "",
"value": ""
},
"options": [],
"multi": false,
"includeAll": false,
"label": "Loki Data Source",
"hide": "dontHide",
"skipUrlSync": false,
"allowCustomValue": true
}
},
{
"kind": "QueryVariable",
"spec": {
"name": "namespace",
"current": {
"text": "",
"value": ""
},
"label": "Namespace",
"hide": "dontHide",
"refresh": "onDashboardLoad",
"skipUrlSync": false,
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "${DS_PROMETHEUS}"
},
"spec": {
"__legacyStringValue": "label_values(kube_pod_info, namespace)"
}
},
"regex": "",
"sort": "disabled",
"options": [],
"multi": true,
"includeAll": true,
"allValue": ".*",
"allowCustomValue": true
}
},
{
"kind": "QueryVariable",
"spec": {
"name": "pod",
"current": {
"text": "",
"value": ""
},
"label": "Pod",
"hide": "dontHide",
"refresh": "onDashboardLoad",
"skipUrlSync": false,
"query": {
"kind": "DataQuery",
"group": "prometheus",
"version": "v0",
"datasource": {
"name": "${DS_PROMETHEUS}"
},
"spec": {
"__legacyStringValue": "label_values(kube_pod_info{namespace=~\"$namespace\"}, pod)"
}
},
"regex": "",
"sort": "disabled",
"options": [],
"multi": true,
"includeAll": true,
"allValue": ".*",
"allowCustomValue": true
}
},
{
"kind": "TextVariable",
"spec": {
"name": "search",
"current": {
"text": "",
"value": ""
},
"query": "",
"label": "Log String Filter",
"hide": "dontHide",
"skipUrlSync": false
}
}
]
}
}

View File

@@ -0,0 +1,635 @@
{
"apiVersion": "dashboard.grafana.app/v2",
"kind": "Dashboard",
"metadata": {
"name": "k3s-pro-logs",
"namespace": "default",
"uid": "4b031c52-1c0a-4a18-8f0e-0c8f3e7e6011",
"resourceVersion": "1786876489507019",
"generation": 1,
"creationTimestamp": "2026-08-16T10:34:49Z",
"labels": {
"grafana.app/deprecatedInternalID": "3770890413830144"
},
"annotations": {
"grafana.app/createdBy": "user:dfbtp4cn32dj4f",
"grafana.app/folder": "",
"grafana.app/saved-from-ui": "Grafana v13.1.1 (a9cee6e172)"
}
},
"spec": {
"annotations": [
{
"kind": "AnnotationQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "grafana",
"version": "v0",
"datasource": {
"name": "-- Grafana --"
},
"spec": {}
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"builtIn": true,
"legacyOptions": {
"type": "dashboard"
}
}
}
],
"cursorSync": "Crosshair",
"editable": true,
"elements": {
"panel-1": {
"kind": "Panel",
"spec": {
"id": 1,
"title": "Critical Events Over Time",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"editorMode": "code",
"expr": "sum(count_over_time({cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\", container=~\"$container\"} !~ \"(?i)(No files matching import glob pattern|v1 Endpoints is deprecated)\" |~ \"(?i)(error|err|fatal|crit|fail|exception)\" [$__interval]))",
"legendFormat": "Errors",
"queryType": "range"
}
},
"refId": "A",
"hidden": false
}
},
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"editorMode": "code",
"expr": "sum(count_over_time({cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\", container=~\"$container\"} !~ \"(?i)(No files matching import glob pattern|v1 Endpoints is deprecated)\" |~ \"(?i)(warn|warning)\" [$__interval]))",
"legendFormat": "Warnings",
"queryType": "range"
}
},
"refId": "B",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "timeseries",
"version": "",
"spec": {
"options": {
"legend": {
"calcs": [
"sum"
],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"value": null,
"color": "green"
},
{
"value": 80,
"color": "red"
}
]
},
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "bars",
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Errors"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "red",
"mode": "fixed"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Warnings"
},
"properties": [
{
"id": "color",
"value": {
"fixedColor": "orange",
"mode": "fixed"
}
}
]
}
]
}
}
}
}
},
"panel-2": {
"kind": "Panel",
"spec": {
"id": 2,
"title": "Top Error-Producing Pods",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"editorMode": "code",
"expr": "topk(5, sum by (pod) (count_over_time({cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\", container=~\"$container\"} !~ \"(?i)(No files matching import glob pattern|v1 Endpoints is deprecated)\" |~ \"(?i)(error|err|fatal|crit|fail|exception)\" [$__range])))",
"legendFormat": "{{pod}}",
"queryType": "range"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "bargauge",
"version": "10.4.0",
"spec": {
"options": {
"displayMode": "gradient",
"minVizHeight": 10,
"minVizWidth": 0,
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showUnfilled": true,
"text": {}
},
"fieldConfig": {
"defaults": {
"unit": "short",
"thresholds": {
"mode": "absolute",
"steps": [
{
"value": null,
"color": "green"
},
{
"value": 1,
"color": "orange"
},
{
"value": 10,
"color": "red"
}
]
},
"color": {
"mode": "thresholds"
}
},
"overrides": []
}
}
}
}
},
"panel-3": {
"kind": "Panel",
"spec": {
"id": 3,
"title": "Live Pod Logs",
"description": "",
"links": [],
"data": {
"kind": "QueryGroup",
"spec": {
"queries": [
{
"kind": "PanelQuery",
"spec": {
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"editorMode": "code",
"expr": "{cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\", container=~\"$container\"} !~ \"(?i)(No files matching import glob pattern|v1 Endpoints is deprecated)\" |~ \"$log_severity\" |~ \"$search\"",
"queryType": "range"
}
},
"refId": "A",
"hidden": false
}
}
],
"transformations": [],
"queryOptions": {}
}
},
"vizConfig": {
"kind": "VizConfig",
"group": "logs",
"version": "",
"spec": {
"options": {
"dedupStrategy": "exact",
"enableLogDetails": true,
"prettifyLogMessage": true,
"showCommonLabels": false,
"showLabels": true,
"showLogLabels": true,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true
},
"fieldConfig": {
"defaults": {},
"overrides": []
}
}
}
}
}
},
"layout": {
"kind": "RowsLayout",
"spec": {
"rows": [
{
"kind": "RowsLayoutRow",
"spec": {
"title": "Log Severity & Anomaly Overview",
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 16,
"height": 7,
"element": {
"kind": "ElementReference",
"name": "panel-1"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 16,
"y": 0,
"width": 8,
"height": 7,
"element": {
"kind": "ElementReference",
"name": "panel-2"
}
}
}
]
}
}
}
},
{
"kind": "RowsLayoutRow",
"spec": {
"title": "Filtered Container Log Stream",
"collapse": false,
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 24,
"height": 18,
"element": {
"kind": "ElementReference",
"name": "panel-3"
}
}
}
]
}
}
}
}
]
}
},
"links": [],
"liveNow": false,
"preload": false,
"tags": [
"k3s",
"loki",
"logs",
"alloy"
],
"timeSettings": {
"timezone": "browser",
"from": "now-1h",
"to": "now",
"autoRefresh": "5s",
"autoRefreshIntervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"hideTimepicker": false,
"fiscalYearStartMonth": 0
},
"title": "K3s Professional Log Analyzer",
"variables": [
{
"kind": "DatasourceVariable",
"spec": {
"name": "DS_LOKI",
"pluginId": "loki",
"refresh": "onDashboardLoad",
"regex": "",
"current": {
"text": "Loki",
"value": "Loki"
},
"options": [],
"multi": false,
"includeAll": false,
"label": "Loki Data Source",
"hide": "dontHide",
"skipUrlSync": false,
"allowCustomValue": true
}
},
{
"kind": "QueryVariable",
"spec": {
"name": "namespace",
"current": {
"text": "All",
"value": "$__all"
},
"label": "Namespace",
"hide": "dontHide",
"refresh": "onDashboardLoad",
"skipUrlSync": false,
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"__legacyStringValue": "label_values({cluster=\"k3s-homeserver\"}, namespace)"
}
},
"regex": "",
"sort": "alphabeticalAsc",
"definition": "label_values({cluster=\"k3s-homeserver\"}, namespace)",
"options": [],
"multi": true,
"includeAll": true,
"allValue": ".*",
"allowCustomValue": true
}
},
{
"kind": "QueryVariable",
"spec": {
"name": "pod",
"current": {
"text": "All",
"value": "$__all"
},
"label": "Pod",
"hide": "dontHide",
"refresh": "onDashboardLoad",
"skipUrlSync": false,
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"__legacyStringValue": "label_values({cluster=\"k3s-homeserver\", namespace=~\"$namespace\"}, pod)"
}
},
"regex": "",
"sort": "alphabeticalAsc",
"definition": "label_values({cluster=\"k3s-homeserver\", namespace=~\"$namespace\"}, pod)",
"options": [],
"multi": true,
"includeAll": true,
"allValue": ".*",
"allowCustomValue": true
}
},
{
"kind": "QueryVariable",
"spec": {
"name": "container",
"current": {
"text": "All",
"value": "$__all"
},
"label": "Container",
"hide": "dontHide",
"refresh": "onDashboardLoad",
"skipUrlSync": false,
"query": {
"kind": "DataQuery",
"group": "loki",
"version": "v0",
"datasource": {
"name": "${DS_LOKI}"
},
"spec": {
"__legacyStringValue": "label_values({cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\"}, container)"
}
},
"regex": "",
"sort": "alphabeticalAsc",
"definition": "label_values({cluster=\"k3s-homeserver\", namespace=~\"$namespace\", pod=~\"$pod\"}, container)",
"options": [],
"multi": true,
"includeAll": true,
"allValue": ".*",
"allowCustomValue": true
}
},
{
"kind": "CustomVariable",
"spec": {
"name": "log_severity",
"query": "Warnings & Errors Only : (?i)(warn|warning|error|err|fatal|crit|fail|exception), Errors Only : (?i)(error|err|fatal|crit|fail|exception), All Logs (Including Info & Debug) : .*",
"current": {
"text": "Warnings & Errors Only",
"value": "(?i)(warn|warning|error|err|fatal|crit|fail|exception)"
},
"options": [
{
"selected": true,
"text": "Warnings & Errors Only",
"value": "(?i)(warn|warning|error|err|fatal|crit|fail|exception)"
},
{
"selected": false,
"text": "Errors Only",
"value": "(?i)(error|err|fatal|crit|fail|exception)"
},
{
"selected": false,
"text": "All Logs (Including Info & Debug)",
"value": ".*"
}
],
"multi": false,
"includeAll": false,
"label": "Log Severity Level",
"hide": "dontHide",
"skipUrlSync": false,
"allowCustomValue": true
}
},
{
"kind": "TextVariable",
"spec": {
"name": "search",
"current": {
"text": "",
"value": ""
},
"query": "",
"label": "Line Search Text",
"hide": "dontHide",
"skipUrlSync": false
}
}
]
}
}