rschmukler / docker-prometheus-rancher-conf

Automatic Prometheus monitoring for Rancher
7 stars 1 forks source link

Rancher Template #1

Open janeczku opened 8 years ago

janeczku commented 8 years ago

Not an issue report, just an FYI: https://github.com/janeczku/rancher-template does this

scrape_configs: {{ range $serviceName := lsdir "/services" }} {{ if exists (printf "/services/%s/labels/prometheus.monitor" $serviceName)}}
    - job_name: {{ getv (printf "/services/%s/name" $serviceName) }}
      target_groups:
      - targets: {{ range $containerId := lsdir (printf "/services/%s/containers" $serviceName) }}
        - '{{ getv (printf "/services/%s/containers/%s/primary_ip" $serviceName $containerId) }}:{{ ( getv (printf "/services/%s/labels/prometheus.monitor.port" $serviceName) "3000") }}' {{ end }} {{ end }} {{end }}

like that

scrape_configs: {{ range services "@prometheus.monitor=.*" }}
    - job_name: {{ .Name }}
      target_groups:
      - targets: {{ range .Containers }}
        - '{{ .Address }}:{{ .Labels.GetValue "prometheus.monitor.port" "3000" }}' {{ end }}{{ end }}

If you find time to check it out please tell me if anything is missing.

rschmukler commented 8 years ago

@janeczku thanks a ton for opening this issue. rancher-template looks great! Will give it a more thorough look and move this over