prometheus_flask_exporter | Prometheus exporter for Flask applications | Dashboard library
kandi X-RAY | prometheus_flask_exporter Summary
kandi X-RAY | prometheus_flask_exporter Summary
Prometheus exporter for Flask applications
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create Flask application
- Register metric decorators
- Setup API endpoint
- Track a counter
- Decorator to track a metric
- Return a combined label for each response
- Register metrics endpoint
- Decorator for methods that will track the request
- Generate metrics
- Start an HTTP server
- Main loop
- Run the function in parallel
- Defines a metric thread
- Start Prometheus metrics
- Check if env var is set
- Start the HTTP server
- Check if we should start HTTP server
- Create a new gauge
- Main thread
prometheus_flask_exporter Key Features
prometheus_flask_exporter Examples and Code Snippets
Community Discussions
Trending Discussions on prometheus_flask_exporter
QUESTION
I'm creating a simple Flask webapp which should generate a random metric to be pulled by Prometheus. I'm using the prometheus-flask-exporter library which enabled me to set a metric.
Put simply, I want to know how can I configure custom metrics internally within flask so that they update at intervals from the '/metrics' endpoint of the flask app.
Not 'how often can I get prometheus to fetch a particular metric'
Currently I can't get a loop working within my flask app as the main class doesn't run if I have one.
This is just for a proof of concept, the custom metric can be anything.
My app.py:
...ANSWER
Answered 2022-Feb-04 at 18:15I am not sure you understood how Prometheus works. By default Prometheus fetches the metrics from the target(s) every 15 seconds, but you can set a different interval. So it will call your endpoint every 15 seconds to retrieve the metrics, unless you decide otherwise. Your endpoint is purely passive and responds to incoming connections as they happen.
If what you want is to collect metrics every 5 seconds, then you have to edit your YAML configuration file on the Prometheus machine. The Flask app does not need changing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install prometheus_flask_exporter
You can use prometheus_flask_exporter like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page