Skip to content

How do I call the function every time before the metrics are given? #862

Answered by vrublevskyyy
vrublevskyyy asked this question in Q&A
Discussion options

You must be logged in to vote

Found solution:

#!/usr/bin/env python
from flask import Flask, Response
from prometheus_client import Gauge, generate_latest, CONTENT_TYPE_LATEST

app = Flask('kayenta-tester')
blabla= Gauge('blabla_execution_time', 'blabla_desc',[])

@app.route('/metrics')
def hello():
    blabla.set(my_func())
    return Response(generate_latest(), mimetype=CONTENT_TYPE_LATEST)

app.run(host = '0.0.0.0', port = 8080)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vrublevskyyy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant