连接celery-flower和prometheus在单独的docker-compose文件中。

huangapple go评论53阅读模式
英文:

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

问题

我想连接 celery-flowerprometheus。我按照这个指南进行操作 - https://github.com/mher/flower/blob/master/docs/prometheus-integration.rst

我有两个 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

但是我在 http://localhost:9090/graph 上看不到 celery-flower。

这两个容器都能够看到 flower 网络(通过 docker inspect)。

prometheus 容器 ping

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

连接

telnet celery-flower 5555
Connected to celery-flower
英文:

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

答案1

得分: 0

不正确的celery-flower运行命令(需要删除--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
英文:

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

huangapple
  • 本文由 发表于 2023年2月19日 22:55:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500996.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定