Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jhoelzel/5fefd89062a833166b8c23e5d393a746 to your computer and use it in GitHub Desktop.
Save jhoelzel/5fefd89062a833166b8c23e5d393a746 to your computer and use it in GitHub Desktop.
Values file for Helm install of Loki for Rancher Monitoring V2 on RKE2
loki:
persistence:
enabled: true
size: 5Gi
serviceMonitor:
enabled: true
promtail:
enabled: true
extraScrapeConfigs:
- job_name: kubernetes-pods-app
pipeline_stages:
- match:
selector: '{app="rke2-ingress-nginx"}'
stages:
- regex:
expression: '^(?P<ts_loki>[\d]+-[\d]+-[\d]+T[\d]+:[\d]+:[\d]+.[\d]+-[\d]+:[\d]+) (?P<output_type>[\w]+) \w (?P<req_source>[^ ]*) [^ ] [^ ] \[[^ ]+ [^ ]+\] "(?P<request_type>[^ ]+) [^ ]+ [^ ]+ (?P<status_code>[\d]+)'
- labels:
status_code:
request_type:
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: drop
regex: .+
source_labels:
- __meta_kubernetes_pod_label_name
- source_labels:
- __meta_kubernetes_pod_label_app
target_label: __service__
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ''
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
source_labels:
- __meta_kubernetes_namespace
- __service__
target_label: job
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: pod
- action: replace
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
- __meta_kubernetes_pod_uid
- __meta_kubernetes_pod_container_name
target_label: __path__
- job_name: kubernetes-pods-static
pipeline_stages:
- match:
selector: '{container="etcd",namespace="kube-system"}'
stages:
- regex:
expression: '^(?P<ts_loki>[\d]+-[\d]+-[\d]+T[\d]+:[\d]+:[\d]+.[\d]+-[\d]+:[\d]+) [\w]+ [\w]+ (?P<message_json>{.*})'
- json:
expressions:
log_level: level
source: message_json
- labels:
log_level:
- match:
selector: '{container=~"kube-apiserver|kube-controller-manager|kube-scheduler",namespace="kube-system"}'
stages:
- regex:
expression: '^(?P<ts_loki>[\d]+-[\d]+-[\d]+T[\d]+:[\d]+:[\d]+.[\d]+-[\d]+:[\d]+) [\w]+ [\w]+ (?P<log_level>\w)'
- labels:
log_level:
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: drop
regex: ''
source_labels:
- __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
- action: replace
source_labels:
- __meta_kubernetes_pod_label_component
target_label: __service__
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ''
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
source_labels:
- __meta_kubernetes_namespace
- __service__
target_label: job
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: pod
- action: replace
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
- __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
- __meta_kubernetes_pod_container_name
target_label: __path__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment