Skip to content

Commit 2220272

Browse files
authoredApr 29, 2024··
chore: refactor promtail extraScrapeConfigs into scrapeConfigs (#367)
## Description Move the `extraScrapeConfig` snippets into the `snippets.scrapeConfigs` and copy/paste the upstream default `scrapeConfig`. This will allow for adding `extraScrapeConfigs` at deploy time via overrides without needing to copy over the default configs provided by core. ## Related Issue is part of completing this PR defenseunicorns/uds-infrastructure#105 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Other (security config, docs update, etc) ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md)(https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md#submitting-a-pull-request) followed
1 parent accdf03 commit 2220272

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed
 

‎src/promtail/values/values.yaml

+50-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,49 @@ config:
33
- url: 'http://loki-gateway.loki.svc.cluster.local:80/loki/api/v1/push'
44

55
snippets:
6-
extraScrapeConfigs: >
6+
scrapeConfigs: |
7+
# Upstream Defaults https://github.com/grafana/helm-charts/blob/main/charts/promtail/values.yaml
8+
# See also https://github.com/grafana/loki/blob/master/production/ksonnet/promtail/scrape_config.libsonnet for reference
9+
- job_name: kubernetes-pods
10+
pipeline_stages:
11+
{{- toYaml .Values.config.snippets.pipelineStages | nindent 4 }}
12+
kubernetes_sd_configs:
13+
- role: pod
14+
relabel_configs:
15+
- source_labels:
16+
- __meta_kubernetes_pod_controller_name
17+
regex: ([0-9a-z-.]+?)(-[0-9a-f]{8,10})?
18+
action: replace
19+
target_label: __tmp_controller_name
20+
- source_labels:
21+
- __meta_kubernetes_pod_label_app_kubernetes_io_name
22+
- __meta_kubernetes_pod_label_app
23+
- __tmp_controller_name
24+
- __meta_kubernetes_pod_name
25+
regex: ^;*([^;]+)(;.*)?$
26+
action: replace
27+
target_label: app
28+
- source_labels:
29+
- __meta_kubernetes_pod_label_app_kubernetes_io_instance
30+
- __meta_kubernetes_pod_label_instance
31+
regex: ^;*([^;]+)(;.*)?$
32+
action: replace
33+
target_label: instance
34+
- source_labels:
35+
- __meta_kubernetes_pod_label_app_kubernetes_io_component
36+
- __meta_kubernetes_pod_label_component
37+
regex: ^;*([^;]+)(;.*)?$
38+
action: replace
39+
target_label: component
40+
{{- if .Values.config.snippets.addScrapeJobLabel }}
41+
- replacement: kubernetes-pods
42+
target_label: scrape_job
43+
{{- end }}
44+
{{- toYaml .Values.config.snippets.common | nindent 4 }}
45+
{{- with .Values.config.snippets.extraRelabelConfigs }}
46+
{{- toYaml . | nindent 4 }}
47+
{{- end }}
48+
# UDS CORE Defaults
749
- job_name: systemd-messages
850
static_configs:
951
- targets: [localhost]
@@ -21,6 +63,13 @@ config:
2163
- source_labels:
2264
- __journal_syslog_identifier
2365
target_label: syslog_identifier
66+
- job_name: kubernetes-logs
67+
static_configs:
68+
- targets: [localhost]
69+
labels:
70+
job: kubernetes-logs
71+
host: "${NODE_HOSTNAME}"
72+
__path__: /var/log/kubernetes/**/*.log
2473
2574
containerSecurityContext:
2675
allowPrivilegeEscalation: false

0 commit comments

Comments
 (0)
Please sign in to comment.