Skip to content

Commit

Permalink
feat: add loki dashboard for kubernetes pods log (#3903)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunju.lly authored and ldming committed Nov 21, 2023
1 parent e96011a commit 77f38cd
Show file tree
Hide file tree
Showing 2 changed files with 308 additions and 0 deletions.
301 changes: 301 additions & 0 deletions helm/dashboards/container-log.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"description": "Basic dashboard for Kubernetes Container Logs from Loki.",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 18494,
"graphTooltip": 0,
"id": 12,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 42,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"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": 10,
"w": 24,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"editorMode": "builder",
"expr": "sum(count_over_time({namespace=~\"$namespace\", pod=~\"$pod\", container=~\"$container\"} |~ `$search` [$__interval]))",
"legendFormat": "{{container}}",
"queryType": "range",
"refId": "A",
"resolution": 4
}
],
"title": "Logs Trend",
"type": "timeseries"
},
{
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"gridPos": {
"h": 26,
"w": 24,
"x": 0,
"y": 10
},
"id": 3,
"options": {
"dedupStrategy": "exact",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": true,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"editorMode": "builder",
"expr": "{namespace=~\"$namespace\", pod=~\"$pod\", container=~\"$container\"} |~ `(?i)$search`",
"queryType": "range",
"refId": "A"
}
],
"title": "Logs Panel",
"type": "logs"
}
],
"refresh": false,
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"allValue": ".+",
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"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": 5,
"type": "query"
},
{
"allValue": ".+",
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"definition": "",
"hide": 0,
"includeAll": true,
"label": "Pod",
"multi": false,
"name": "pod",
"options": [],
"query": {
"label": "pod",
"refId": "LokiVariableQueryEditor-VariableQuery",
"stream": "{namespace=~\"$namespace\"}",
"type": 1
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 5,
"type": "query"
},
{
"allValue": ".+",
"current": {
"selected": false,
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "loki",
"uid": "loki-kubeblocks"
},
"definition": "",
"hide": 0,
"includeAll": true,
"label": "Container",
"multi": false,
"name": "container",
"options": [],
"query": {
"label": "container",
"refId": "LokiVariableQueryEditor-VariableQuery",
"stream": "{namespace=~\"$namespace\", pod=~\"$pod\"}",
"type": 1
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 5,
"type": "query"
},
{
"current": {
"selected": false,
"text": "",
"value": ""
},
"hide": 0,
"label": "Search Term",
"name": "search",
"options": [
{
"selected": true,
"text": "",
"value": ""
}
],
"query": "",
"skipUrlSync": false,
"type": "textbox"
}
]
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"timezone": "",
"title": "Container Logs",
"uid": "container-logs",
"version": 1,
"weekStart": ""
}
7 changes: 7 additions & 0 deletions helm/templates/grafana/configmaps-datasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ data:
isDefault: false
jsonData:
timeInterval: 15s
- name: Loki
type: loki
uid: loki-kubeblocks
access: proxy
url: http://loki-gateway:80
jsonData:
maxLines: 1000
{{- end }}
{{- end }}

0 comments on commit 77f38cd

Please sign in to comment.