Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 1.88 KB

README.md

File metadata and controls

67 lines (51 loc) · 1.88 KB

Prometheus Config Merger

Sidecar to merge Prometheus configuration from multiple ConfigMaps and save it to file.

It is supposed to run as sidecar for Prometheus.

How does it work

  1. Watch the changes to configmaps with specific label.
  2. On any change get the contents from all watched ConfigMaps.
  3. Merge the content together as yaml.
  4. Write the yaml content to file.
  5. Hit Prometheus reload API to reload the file.

How to run

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

Integrating with Prometheus Community helm chart

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