Skip to content

Commit a4a73ed

Browse files
committed
added host logs + dashboard
1 parent 7d5488b commit a4a73ed

File tree

3 files changed

+265
-0
lines changed

3 files changed

+265
-0
lines changed
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
{
2+
"annotations": {
3+
"list": [
4+
{
5+
"builtIn": 1,
6+
"datasource": {
7+
"type": "grafana",
8+
"uid": "-- Grafana --"
9+
},
10+
"enable": true,
11+
"hide": true,
12+
"iconColor": "rgba(0, 211, 255, 1)",
13+
"name": "Annotations & Alerts",
14+
"type": "dashboard"
15+
}
16+
]
17+
},
18+
"description": "Search systemd logs stored in Loki",
19+
"editable": false,
20+
"fiscalYearStartMonth": 0,
21+
"graphTooltip": 0,
22+
"id": 33,
23+
"links": [],
24+
"panels": [
25+
{
26+
"datasource": "Loki",
27+
"fieldConfig": {
28+
"defaults": {
29+
"color": {
30+
"mode": "palette-classic"
31+
},
32+
"custom": {
33+
"axisBorderShow": false,
34+
"axisCenteredZero": false,
35+
"axisColorMode": "text",
36+
"axisLabel": "",
37+
"axisPlacement": "hidden",
38+
"barAlignment": 0,
39+
"barWidthFactor": 0.6,
40+
"drawStyle": "bars",
41+
"fillOpacity": 100,
42+
"gradientMode": "none",
43+
"hideFrom": {
44+
"legend": false,
45+
"tooltip": false,
46+
"viz": false
47+
},
48+
"insertNulls": false,
49+
"lineInterpolation": "linear",
50+
"lineWidth": 1,
51+
"pointSize": 5,
52+
"scaleDistribution": {
53+
"type": "linear"
54+
},
55+
"showPoints": "never",
56+
"spanNulls": false,
57+
"stacking": {
58+
"group": "A",
59+
"mode": "none"
60+
},
61+
"thresholdsStyle": {
62+
"mode": "off"
63+
}
64+
},
65+
"mappings": [],
66+
"thresholds": {
67+
"mode": "absolute",
68+
"steps": [
69+
{
70+
"color": "green",
71+
"value": null
72+
},
73+
{
74+
"color": "red",
75+
"value": 80
76+
}
77+
]
78+
},
79+
"unit": "short"
80+
},
81+
"overrides": []
82+
},
83+
"gridPos": {
84+
"h": 3,
85+
"w": 24,
86+
"x": 0,
87+
"y": 0
88+
},
89+
"id": 6,
90+
"options": {
91+
"legend": {
92+
"calcs": [],
93+
"displayMode": "list",
94+
"placement": "bottom",
95+
"showLegend": false
96+
},
97+
"tooltip": {
98+
"mode": "multi",
99+
"sort": "none"
100+
}
101+
},
102+
"targets": [
103+
{
104+
"datasource": "Loki",
105+
"expr": "sum(count_over_time({unit=~\"$unit\", hostname=~\"$hostname\"} |~ \"$search\"[$__interval]))",
106+
"refId": "A"
107+
}
108+
],
109+
"type": "timeseries"
110+
},
111+
{
112+
"datasource": "Loki",
113+
"gridPos": {
114+
"h": 25,
115+
"w": 24,
116+
"x": 0,
117+
"y": 3
118+
},
119+
"id": 2,
120+
"maxDataPoints": "",
121+
"options": {
122+
"dedupStrategy": "none",
123+
"enableLogDetails": true,
124+
"prettifyLogMessage": false,
125+
"showCommonLabels": false,
126+
"showLabels": false,
127+
"showTime": true,
128+
"sortOrder": "Descending",
129+
"wrapLogMessage": true
130+
},
131+
"targets": [
132+
{
133+
"datasource": "Loki",
134+
"expr": "{unit=~\"$unit\", hostname=~\"$hostname\"} |~ \"$search\"",
135+
"refId": "A"
136+
}
137+
],
138+
"title": "Logs Panel",
139+
"type": "logs"
140+
}
141+
],
142+
"schemaVersion": 39,
143+
"tags": [],
144+
"templating": {
145+
"list": [
146+
{
147+
"allValue": ".+",
148+
"current": {
149+
"selected": true,
150+
"text": "ansible-init.service",
151+
"value": "ansible-init.service"
152+
},
153+
"datasource": "Loki",
154+
"definition": "label_values(unit)",
155+
"hide": 0,
156+
"includeAll": false,
157+
"multi": false,
158+
"name": "unit",
159+
"options": [],
160+
"query": "label_values(unit)",
161+
"refresh": 1,
162+
"regex": "",
163+
"skipUrlSync": false,
164+
"sort": 0,
165+
"tagValuesQuery": "",
166+
"tagsQuery": "",
167+
"type": "query",
168+
"useTags": false
169+
},
170+
{
171+
"allValue": ".+",
172+
"current": {
173+
"selected": true,
174+
"text": [
175+
"All"
176+
],
177+
"value": [
178+
"$__all"
179+
]
180+
},
181+
"datasource": "Loki",
182+
"definition": "label_values({unit=~\"$unit\"}, hostname)",
183+
"hide": 0,
184+
"includeAll": true,
185+
"multi": true,
186+
"name": "hostname",
187+
"options": [],
188+
"query": "label_values({unit=~\"$unit\"}, hostname)",
189+
"refresh": 1,
190+
"regex": "",
191+
"skipUrlSync": false,
192+
"sort": 0,
193+
"tagValuesQuery": "",
194+
"tagsQuery": "",
195+
"type": "query",
196+
"useTags": false
197+
},
198+
{
199+
"current": {},
200+
"hide": 0,
201+
"name": "search",
202+
"options": [],
203+
"query": "",
204+
"skipUrlSync": false,
205+
"type": "textbox"
206+
}
207+
]
208+
},
209+
"time": {
210+
"from": "now-3h",
211+
"to": "now"
212+
},
213+
"timepicker": {
214+
"refresh_intervals": [
215+
"5s",
216+
"10s",
217+
"30s",
218+
"1m",
219+
"5m",
220+
"15m",
221+
"30m",
222+
"1h",
223+
"2h",
224+
"1d"
225+
]
226+
},
227+
"timezone": "",
228+
"title": "Loki / Systemd Logs",
229+
"uid": "fa1bd43aed803111be9cc923cada9811",
230+
"version": 1,
231+
"weekStart": ""
232+
}

ansible/roles/kube_prometheus_stack/tasks/main.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,37 @@
193193
sidecar:
194194
datasources:
195195
enabled: false
196+
promtail:
197+
config:
198+
snippets:
199+
extraScrapeConfigs: |
200+
- job_name: journal
201+
journal:
202+
path: /var/log/journal
203+
max_age: 12h
204+
labels:
205+
job: systemd-journal
206+
relabel_configs:
207+
- source_labels: ['__journal__systemd_unit']
208+
target_label: 'unit'
209+
- source_labels: ['__journal__hostname']
210+
target_label: 'hostname'
211+
- source_labels: ['__journal_priority_keyword']
212+
target_label: level
213+
extraVolumes:
214+
- name: journal
215+
hostPath:
216+
path: /var/log/journal
217+
- name: machine-id
218+
hostPath:
219+
path: /etc/machine-id
220+
extraVolumeMounts:
221+
- name: journal
222+
mountPath: /var/log/journal
223+
readOnly: true
224+
- name: machine-id
225+
mountPath: /etc/machine-id
226+
readOnly: true
196227
wait: yes
197228

198229
- name: Install kube-prometheus-stack on target Kubernetes cluster

environments/common/inventory/group_vars/all/grafana.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ grafana_dashboards_default:
4040
revision_id: 3
4141
- dashboard_file: loki-pod-logs-dashboard.json
4242
replacements: []
43+
- dashboard_file: loki-systemd-logs-dashboard.json
44+
replacements: []
4345
grafana_dashboards: "{{ grafana_dashboards_default + (openondemand_dashboard if groups.get('openondemand') else []) }}"
4446

4547
# Configmap names of kube prometheus stack's default dashboards to exclude

0 commit comments

Comments
 (0)