docker-composeceleryprometheusdocker-networkflower

Connect celery-flower and prometheus in separate docker-compose files


I want to connect celery-flower and prometheus. I work following this instruction - https://github.com/mher/flower/blob/master/docs/prometheus-integration.rst

I have 2 docker-compose.yml.

app/docker-compose.yml

  celery-flower:
    ...
    container_name: celery-flower
    command: celery -A configs flower -l INFO --url_prefix=flower --port=5555 --persisten=True
    ports:
      - "5555:5555"
    networks:
      - default
      - flower

networks:
  default:
  flower:
    external: true

observability/docker-compose.yml

  prometheus:
    ...
    volumes:
      - $PWD/prometheus.yml:/etc/prometheus/prometheus.yml
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--web.enable-lifecycle'
    expose:
      - 9090
    ports:
       - 9090:9090
    networks:
      - observability
      - flower

networks:
  observability:
  flower:
    external: true

observability/prometheus.yml

scrape_configs:
- job_name: flower
  static_configs:
  - targets:
    - celery-flower:5555

But i don't see celery-flower on the http://localhost:9090/graph

Both containers see the flower network (via docker inspect)

Ping from prometheus container

PING celery-flower (172.21.0.3): 56 data bytes
64 bytes from 172.21.0.3: seq=0 ttl=64 time=0.122 ms
64 bytes from 172.21.0.3: seq=1 ttl=64 time=0.113 ms
64 bytes from 172.21.0.3: seq=2 ttl=64 time=0.116 ms
64 bytes from 172.21.0.3: seq=3 ttl=64 time=0.093 ms
64 bytes from 172.21.0.3: seq=4 ttl=64 time=0.072 ms
64 bytes from 172.21.0.3: seq=5 ttl=64 time=0.076 ms
--- celery-flower ping statistics ---
6 packets transmitted, 6 packets received, 0% packet loss
round-trip min/avg/max = 0.072/0.098/0.122 ms

Connection

telnet celery-flower 5555
Connected to celery-flower

Solution

  • Incorrect command for celery-flower running (need to remove --url_prefix=flower)

    app/docker-compose.yml

      celery-flower:
        restart: always
        image: mher/flower:1.2.0
        container_name: celery-flower
        command: celery flower -l INFO --persisten=True
        volumes:
          - flower_data:/data
        environment:
          - CELERY_BROKER_URL=redis://redis:6379
        ports:
          - 5555:5555
        networks:
          - default
          - flower