Search code examples
docker-composeprometheus

How to set up log level in a docker-compose


I have a docker-compose launching multiple stuff, one of them is prometheus. Issue is, I can't set up the log-level with command as it with break the default entrypoint:

> docker logs 82d94676cc25
ts=2024-06-23T11:44:23.194Z caller=main.go:487 level=error msg="Error loading config (--config.file=prometheus.yml)" file=/prometheus/prometheus.yml err="open prometheus.yml: no such file or directory"

Is there an environment var that I can set up for the logs in the compose? I couldn't find this anywhere.

My current service:

  jeeo-prometheus:
    image: prom/prometheus:v2.48.1
    volumes:
      - ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"

Solution

  • You can reproduce default parameters in command of your docker compose file: it's only four lines

    Based on current config you need something like this:

      jeeo-prometheus:
        image: prom/prometheus:v2.48.1
        volumes:
          - ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
        ports:
          - "9090:9090"
        command:
          - "--config.file=/etc/prometheus/prometheus.yml"
          - "--storage.tsdb.path=/prometheus"
          - "--web.console.libraries=/usr/share/prometheus/console_libraries"
          - "--web.console.templates=/usr/share/prometheus/consoles"
          - "--log.level=info"