I want to deploy Prometheus from the official helm chart on the stable
repo.
Also, I want to add my own scrape config.
I can successfully add extra configs directly from the values.yml
file of the chart, after downloading and altering it, but when I try to pass it as argument with --set
nothing happens.
This works [in values.yml
]:
# adds additional scrape configs to prometheus.yml
# must be a string so you have to add a | after extraScrapeConfigs:
# example adds prometheus-blackbox-exporter scrape config
extraScrapeConfigs: |
- job_name: 'sample-job'
scrape_interval: 1s
metrics_path: /
kubernetes_sd_configs:
- role: endpoints
this does not:
sudo helm upgrade --install prometheus \
--set rbac.create=true \
--set server.persistentVolume.enabled=false \
--set alertmanager.persistentVolume.enabled=false \
--set alertmanager.enabled=false \
--set kubeStateMetrics.enabled=false \
--set nodeExporter.enabled=false \
--set pushgateway.enabled=false \
--set extraScrapeConfigs="|
- job_name: 'sample-pods'
scrape_interval: 1s
metrics_path: /
kubernetes_sd_configs:
- role: endpoints
" \
stable/prometheus
Is it possible someway?
I found this SO question How to use --set to set values with Prometheus chart? , but I cannot find a way to apply it to my case.
When we are going to inject a multi-line text into values we need to deal with indentation in YAML.
For your particular case it is:
sudo helm upgrade --install prometheus \
--set rbac.create=true \
--set server.persistentVolume.enabled=false \
--set alertmanager.persistentVolume.enabled=false \
--set alertmanager.enabled=false \
--set kubeStateMetrics.enabled=false \
--set nodeExporter.enabled=false \
--set pushgateway.enabled=false \
--set extraScrapeConfigs="- job_name: 'sample-pods'
scrape_interval: 1s
metrics_path: /
kubernetes_sd_configs:
- role: endpoints" \
stable/prometheus
The more elegant way is to use --set-file key=filepath
construction instead of --set
:
1. We create extraScrapeConfigs.yaml
and put there our value as is:
- job_name: 'sample-pods'
scrape_interval: 1s
metrics_path: /
kubernetes_sd_configs:
- role: endpoints
2. We deploy stable/prometheus
helm chart:
sudo helm upgrade --install prometheus \
--set rbac.create=true \
--set server.persistentVolume.enabled=false \
--set alertmanager.persistentVolume.enabled=false \
--set alertmanager.enabled=false \
--set kubeStateMetrics.enabled=false \
--set nodeExporter.enabled=false \
--set pushgateway.enabled=false \
--set-file extraScrapeConfigs=extraScrapeConfigs.yaml \
stable/prometheus
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With