Bruno Kuasney
12/01/2021, 8:59 AMpushgateway_url
parameter).
how is suppose to work that example since I’m not able to hit the endpoint? I also kinda forced the endpoint to be created by using
start_http_server(8000)
from prometheus_client
.
Like I said, is not breaking the code, so maybe is working, I’m just not able to see it somehow.Anna Geller
12/01/2021, 10:08 AMBruno Kuasney
12/01/2021, 10:12 AMmy_project.run()
reference image:Anna Geller
12/01/2021, 10:14 AMBruno Kuasney
12/01/2021, 10:22 AMstate_handler=[send_notification, prometheus_test]
So, basically, every time my task runs I increment my prometheus gauge and I can see this working on my endpoint 8000 (image attached).
---
In short, what I’m doing is like this:
with Flow(f"{project_name}", schedule=schedule, state_handlers=[send_notification, prometheus_test]) as protect:
...
...
...
where my prometheus_test
is sth like this: (is not finished ofc, is just kinda a POC)
# declared at the beginning (outside the function)
g = Gauge('my_inprogress_requests_protect', 'Count requests to process Protect')
# function to increment every time a tasks run
def prometheus_test(obj, old_state, new_state):
g.inc()
so when I hit localhost:8000 I can see how many time this task ran:Anna Geller
12/01/2021, 10:26 AMBruno Kuasney
12/01/2021, 10:29 AMdavzucky
12/01/2021, 12:30 PMBruno Kuasney
12/01/2021, 2:21 PMAnna Geller
12/01/2021, 2:31 PMBruno Kuasney
12/01/2021, 2:33 PMAnna Geller
12/01/2021, 2:41 PM{
task_run_aggregate(
where: {task_id: {_eq: "5f3c4446-f7f3-423c-b8ad-59005b497a2b"}}
) {
nodes {
task {
name
}
end_time
}
aggregate {
count
}
}
}
davzucky
12/01/2021, 4:08 PMBruno Kuasney
12/02/2021, 8:29 AMTyler Wanner
12/21/2021, 5:25 PM