Sidecar to merge Prometheus configuration from multiple ConfigMaps and save it to file.
It is supposed to run as sidecar for Prometheus.
- Watch the changes to configmaps with specific label.
- On any change get the contents from all watched ConfigMaps.
- Merge the content together as yaml.
- Write the yaml content to file.
- Hit Prometheus reload API to reload the file.
Setup Python environment the standard way:
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
Run the program:
python3 -m merger \
--prometheus-config-file-path "my-test-config.yaml" \
--label-selector=my-org.io/prometheus-merge-config=1 \
--namespace "monitoring" \
--reload-url "http://localhost:9090/-/reload" \
--logging-level INFO
If you want to use this sidecar with prometheus-community helm chart, you need to add this container as a sidecar, create common volume and mount it.
Here is example:
server:
sidecarContainers:
prometheus-config-merger:
image: lirt/prometheus-config-merger:0.1.0
imagePullPolicy: IfNotPresent
args:
- --prometheus-config-file-path=/etc/config-prometheus/prometheus.yml
- --label-selector=my-org.io/prometheus-merge-config=1 \
- --namespace "monitoring" \
- --reload-url "http://localhost:9090/-/reload" \
- --logging-level INFO
volumeMounts:
- name: prometheus-merged-config
mountPath: /etc/config-prometheus/
extraVolumeMounts:
- name: prometheus-merged-config
mountPath: /etc/config-prometheus/
extraVolumes:
- name: prometheus-merged-config
emptyDir: {}
configPath: /etc/config-prometheus/prometheus.yml