Skip to content

Commit 6244c24

Browse files
committed
refactored loki play
1 parent a4a73ed commit 6244c24

File tree

5 files changed

+49
-44
lines changed

5 files changed

+49
-44
lines changed

ansible/roles/grafana-dashboards/files/loki-pod-logs-dashboard.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
]
1717
},
1818
"description": "Search pod logs stored in Loki",
19-
"editable": false,
19+
"editable": true,
2020
"fiscalYearStartMonth": 0,
2121
"graphTooltip": 0,
2222
"id": 31,

ansible/roles/grafana-dashboards/files/loki-systemd-logs-dashboard.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
]
1717
},
1818
"description": "Search systemd logs stored in Loki",
19-
"editable": false,
19+
"editable": true,
2020
"fiscalYearStartMonth": 0,
2121
"graphTooltip": 0,
2222
"id": 33,

ansible/roles/kube_prometheus_stack/defaults/main/helm.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,45 @@ kube_prometheus_stack_release_values: >-
193193
kube_prometheus_stack_release_defaults |
194194
combine(kube_prometheus_stack_release_overrides, recursive = True)
195195
}}
196+
197+
kube_prometheus_stack_loki_release_values:
198+
loki:
199+
nodeSelector:
200+
clusterrole: server
201+
image:
202+
tag: "{{ kube_prometheus_stack_loki_image_tag }}"
203+
grafana:
204+
sidecar:
205+
datasources:
206+
enabled: false
207+
promtail:
208+
config:
209+
snippets:
210+
extraScrapeConfigs: |
211+
- job_name: journal
212+
journal:
213+
path: /var/log/journal
214+
max_age: 12h
215+
labels:
216+
job: systemd-journal
217+
relabel_configs:
218+
- source_labels: ['__journal__systemd_unit']
219+
target_label: 'unit'
220+
- source_labels: ['__journal__hostname']
221+
target_label: 'hostname'
222+
- source_labels: ['__journal_priority_keyword']
223+
target_label: level
224+
extraVolumes:
225+
- name: journal
226+
hostPath:
227+
path: /var/log/journal
228+
- name: machine-id
229+
hostPath:
230+
path: /etc/machine-id
231+
extraVolumeMounts:
232+
- name: journal
233+
mountPath: /var/log/journal
234+
readOnly: true
235+
- name: machine-id
236+
mountPath: /etc/machine-id
237+
readOnly: true

ansible/roles/kube_prometheus_stack/defaults/main/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ kube_prometheus_stack_wait_timeout: 5m
2020
kube_prometheus_stack_metrics_image_tag: v2.12.0
2121
kube_prometheus_stack_patch_image_tag: v20221220-controller-v1.5.1-58-g787ea74b6
2222

23+
kube_prometheus_stack_loki_chart_version: 2.10.2
24+
kube_prometheus_stack_loki_image_tag: 2.9.3
25+
2326
control_ip: "{{ hostvars[groups['control'].0].ansible_host }}"
2427

2528
grafana_auth_anonymous: false

ansible/roles/kube_prometheus_stack/tasks/main.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -180,50 +180,10 @@
180180
kubernetes.core.helm:
181181
chart_ref: loki-stack
182182
chart_repo_url: https://grafana.github.io/helm-charts
183-
chart_version: 2.10.2
183+
chart_version: "{{ kube_prometheus_stack_loki_chart_version }}"
184184
release_name: loki
185185
release_namespace: "{{ kube_prometheus_stack_release_namespace }}"
186-
release_values:
187-
loki:
188-
nodeSelector:
189-
clusterrole: server
190-
image:
191-
tag: 2.9.3
192-
grafana:
193-
sidecar:
194-
datasources:
195-
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
186+
release_values: "{{ kube_prometheus_stack_loki_release_values }}"
227187
wait: yes
228188

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

0 commit comments

Comments
 (0)