Dan*_*iev 4 python celery prometheus
我正在尝试使用 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)
你能向我解释一下我做错了什么吗?
我尝试了现有的 Celery 导出器 (OvalMoney/celery-exporter),发现一些指标丢失或无效。
我在这里编写了一个导出器,用于监视任务状态 - https://github.com/danihodovic/celery-exporter。