Skip to content

Commit

Permalink
chore: refactor promtail extraScrapeConfigs into scrapeConfigs (#367)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
TristanHoladay committed Apr 29, 2024
1 parent accdf03 commit 2220272
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/promtail/values/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,49 @@ config:
- url: 'http://loki-gateway.loki.svc.cluster.local:80/loki/api/v1/push'

snippets:
extraScrapeConfigs: >
scrapeConfigs: |
# Upstream Defaults https://github.com/grafana/helm-charts/blob/main/charts/promtail/values.yaml
# See also https://github.com/grafana/loki/blob/master/production/ksonnet/promtail/scrape_config.libsonnet for reference
- job_name: kubernetes-pods
pipeline_stages:
{{- toYaml .Values.config.snippets.pipelineStages | nindent 4 }}
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_controller_name
regex: ([0-9a-z-.]+?)(-[0-9a-f]{8,10})?
action: replace
target_label: __tmp_controller_name
- source_labels:
- __meta_kubernetes_pod_label_app_kubernetes_io_name
- __meta_kubernetes_pod_label_app
- __tmp_controller_name
- __meta_kubernetes_pod_name
regex: ^;*([^;]+)(;.*)?$
action: replace
target_label: app
- source_labels:
- __meta_kubernetes_pod_label_app_kubernetes_io_instance
- __meta_kubernetes_pod_label_instance
regex: ^;*([^;]+)(;.*)?$
action: replace
target_label: instance
- source_labels:
- __meta_kubernetes_pod_label_app_kubernetes_io_component
- __meta_kubernetes_pod_label_component
regex: ^;*([^;]+)(;.*)?$
action: replace
target_label: component
{{- if .Values.config.snippets.addScrapeJobLabel }}
- replacement: kubernetes-pods
target_label: scrape_job
{{- end }}
{{- toYaml .Values.config.snippets.common | nindent 4 }}
{{- with .Values.config.snippets.extraRelabelConfigs }}
{{- toYaml . | nindent 4 }}
{{- end }}
# UDS CORE Defaults
- job_name: systemd-messages
static_configs:
- targets: [localhost]
Expand All @@ -21,6 +63,13 @@ config:
- source_labels:
- __journal_syslog_identifier
target_label: syslog_identifier
- job_name: kubernetes-logs
static_configs:
- targets: [localhost]
labels:
job: kubernetes-logs
host: "${NODE_HOSTNAME}"
__path__: /var/log/kubernetes/**/*.log
containerSecurityContext:
allowPrivilegeEscalation: false
Expand Down

0 comments on commit 2220272

Please sign in to comment.