2

Hi I want to use the haproxy exporter provided here https://github.com/prometheus/haproxy_exporter in a docker container.

I am using docker-composefor managing containers and want to recreate this command:

$ docker run -p 9101:9101 prom/haproxy-exporter -haproxy.scrape-uri="http://user:[email protected]/haproxy?stats;csv"

in my docker-compose.yml.

I am not sure how to pass the argument, after viewing the docker-compose documentation I tried it like this:

  haproxy-exporter:
    image: prom/haproxy-exporter
    ports:
      - 9101:9101
    network_mode: "host"
    build:
      args:
        - haproxy.scrape-uri="http://user:[email protected]/haproxy?stats;csv"

But this gives me an file is invalid message because it requires a context with a build.

Thanks for any help in advance

1 Answer 1

2

The image is already built and pulled from the hub (unless you have your own Dockerfile) so you don't need the build option. Instead, pass your arguments as the command since the image appears to use an entrypoint (if their Dockerfile only had a cmd option, then you'd need to also pass /bin/haproxy-exporter in your command):

 haproxy-exporter:
    image: prom/haproxy-exporter
    ports:
      - 9101:9101
    network_mode: "host"
    command: -haproxy.scrape-uri="http://user:[email protected]/haproxy?stats;csv"
Sign up to request clarification or add additional context in comments.

2 Comments

Hm after a while I am getting: Can't scrape HAProxy: Get http://localhost/;csv: dial tcp: 127.0.0.1:80: getsockopt: connection refused source=haproxy_exporter.go:309 so it seems the argument is still not forwarded correctly
Ok I got it! the - before the argument was missing in your solution! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.