169 lines
5.5 KiB
YAML
169 lines
5.5 KiB
YAML
{{- if and .Values.monitoring.enabled .Values.monitoring.lokiStack.enabled }}
|
||
---
|
||
apiVersion: v1
|
||
kind: Secret
|
||
metadata:
|
||
name: {{ include "cluster-addons.componentName" (list . "loki-stack") }}-config
|
||
labels:
|
||
{{- include "cluster-addons.componentLabels" (list . "loki-stack") | nindent 4 }}
|
||
addons.stackhpc.com/watch: ""
|
||
stringData:
|
||
defaults: |
|
||
loki:
|
||
serviceMonitor:
|
||
enabled: true
|
||
promtail:
|
||
serviceMonitor:
|
||
enabled: true
|
||
# Get promtail to scrape systemd services
|
||
config:
|
||
snippets:
|
||
extraScrapeConfigs: |
|
||
- job_name: journal
|
||
journal:
|
||
path: /var/log/journal
|
||
max_age: 12h
|
||
labels:
|
||
job: systemd-journal
|
||
relabel_configs:
|
||
- source_labels: ['__journal__systemd_unit']
|
||
target_label: 'unit'
|
||
- source_labels: ['__journal__hostname']
|
||
target_label: 'hostname'
|
||
- source_labels: ['__journal_priority_keyword']
|
||
target_label: level
|
||
# Mount journal directory and machine-id file into promtail pods
|
||
extraVolumes:
|
||
- name: journal
|
||
hostPath:
|
||
path: /var/log/journal
|
||
- name: machine-id
|
||
hostPath:
|
||
path: /etc/machine-id
|
||
extraVolumeMounts:
|
||
- name: journal
|
||
mountPath: /var/log/journal
|
||
readOnly: true
|
||
- name: machine-id
|
||
mountPath: /etc/machine-id
|
||
readOnly: true
|
||
grafana:
|
||
sidecar:
|
||
datasources:
|
||
enabled: false
|
||
overrides: |
|
||
{{- toYaml .Values.monitoring.lokiStack.release.values | nindent 4 }}
|
||
---
|
||
apiVersion: addons.stackhpc.com/v1alpha1
|
||
kind: HelmRelease
|
||
metadata:
|
||
name: {{ include "cluster-addons.componentName" (list . "loki-stack") }}
|
||
labels: {{ include "cluster-addons.componentLabels" (list . "loki-stack") | nindent 4 }}
|
||
annotations:
|
||
# Tell Argo to ignore the non-controller owner references for this object
|
||
argocd.argoproj.io/sync-options: "ControllerReferencesOnly=true"
|
||
spec:
|
||
clusterName: {{ include "cluster-addons.clusterName" . }}
|
||
bootstrap: true
|
||
chart: {{ toYaml .Values.monitoring.lokiStack.chart | nindent 4 }}
|
||
targetNamespace: {{ .Values.monitoring.lokiStack.release.namespace }}
|
||
releaseName: loki-stack
|
||
valuesSources:
|
||
- secret:
|
||
name: {{ include "cluster-addons.componentName" (list . "loki-stack") }}-config
|
||
key: defaults
|
||
- secret:
|
||
name: {{ include "cluster-addons.componentName" (list . "loki-stack") }}-config
|
||
key: overrides
|
||
# StatefulSets do not allow their PVCs to be resized, but we can use lifecycle hooks
|
||
# to ensure that it happens correctly
|
||
lifecycleHooks:
|
||
preUpgrade:
|
||
- apiVersion: apps/v1
|
||
kind: StatefulSet
|
||
name: loki-stack
|
||
action: delete
|
||
{{- if .Values.monitoring.lokiStack.release.values.loki.persistence.enabled }}
|
||
- apiVersion: v1
|
||
kind: PersistentVolumeClaim
|
||
selector:
|
||
app: loki
|
||
release: loki-stack
|
||
action: patch
|
||
options:
|
||
data:
|
||
spec:
|
||
resources:
|
||
requests:
|
||
storage: {{ .Values.monitoring.lokiStack.release.values.loki.persistence.size }}
|
||
{{- else }}
|
||
postUpgrade:
|
||
- apiVersion: v1
|
||
kind: PersistentVolumeClaim
|
||
selector:
|
||
app: loki
|
||
release: loki-stack
|
||
action: delete
|
||
{{- end }}
|
||
# After deleting the release, remove the PVCs
|
||
postDelete:
|
||
- apiVersion: v1
|
||
kind: PersistentVolumeClaim
|
||
selector:
|
||
app: loki
|
||
release: loki-stack
|
||
action: delete
|
||
---
|
||
apiVersion: addons.stackhpc.com/v1alpha1
|
||
kind: Manifests
|
||
metadata:
|
||
name: {{ include "cluster-addons.componentName" (list . "loki-stack-dashboards") }}
|
||
labels: {{ include "cluster-addons.componentLabels" (list . "loki-stack-dashboards") | nindent 4 }}
|
||
annotations:
|
||
# Tell Argo to ignore the non-controller owner references for this object
|
||
argocd.argoproj.io/sync-options: "ControllerReferencesOnly=true"
|
||
spec:
|
||
clusterName: {{ include "cluster-addons.clusterName" . }}
|
||
bootstrap: true
|
||
targetNamespace: {{ .Values.monitoring.lokiStack.release.namespace }}
|
||
releaseName: loki-stack-dashboards
|
||
manifestSources:
|
||
- template: |
|
||
apiVersion: v1
|
||
kind: ConfigMap
|
||
metadata:
|
||
name: loki-stack-grafana-datasource
|
||
labels:
|
||
grafana_datasource: "1"
|
||
data:
|
||
loki-datasource.yaml: |-
|
||
apiVersion: 1
|
||
datasources:
|
||
- name: Loki
|
||
type: loki
|
||
url: http://loki-stack.{{ .Values.monitoring.lokiStack.release.namespace }}:3100
|
||
access: proxy
|
||
version: 1
|
||
isDefault: false
|
||
- template: |
|
||
apiVersion: v1
|
||
kind: ConfigMap
|
||
metadata:
|
||
name: loki-stack-grafana-dashboards
|
||
labels:
|
||
grafana_dashboard: "1"
|
||
data:
|
||
loki-pod-logs-dashboard.json: |
|
||
{% raw %}
|
||
{{- .Files.Get "grafana-dashboards/loki-pod-logs-dashboard.json" | nindent 12 }}
|
||
{% endraw %}
|
||
loki-systemd-logs-dashboard.json: |
|
||
{% raw %}
|
||
{{- .Files.Get "grafana-dashboards/loki-systemd-logs-dashboard.json" | nindent 12 }}
|
||
{% endraw %}
|
||
loki-metrics-dashboard.json: |
|
||
{% raw %}
|
||
{{- .Files.Get "grafana-dashboards/loki-metrics-dashboard.json" | nindent 12 }}
|
||
{% endraw %}
|
||
{{- end }}
|