小编Dan*_*iev的帖子

如何使用 Prometheus 监控 Celery 任务完成情况

我正在尝试使用 Prometheus 来监视 Celery 任务,对于该任务我是相对较新的,并且在增加计数器时遇到问题。如果我试图在里面做它只是不会增加Celery.task

例如

from celery import Celery
from prometheus_client import Counter

app = Celery('tasks', broker='redis://localhost')
TASKS = Counter('tasks', 'Count of tasks')


@app.task
def add(x, y):
    TASKS.inc(1)
    return x + y
Run Code Online (Sandbox Code Playgroud)

当我访问端点以查看公开了哪些指标时,我可以看到,但无论执行了tasks_total多少任务,其值都不会改变。add但是,当我尝试从常规函数增加相同的计数器时,它起作用了。

例如

def dummy_add(x, y):
    TASKS.inc()
    return x + y
Run Code Online (Sandbox Code Playgroud)

你能向我解释一下我做错了什么吗?

python celery prometheus

4
推荐指数
1
解决办法
8522
查看次数

标签 统计

celery ×1

prometheus ×1

python ×1