Quickly run queries on prometheus and view results on csv and pdf reports with plots.
This file contains a list of Prometheus metrics to be collected.
By default, metrics are listed in file: config/metrics.txt
If you want to use a custom metrics file, place it in config directory: e.g. config/metrics_haproxy.txt
Run prometheus and node exporter with docker-compose:
docker-compose up -d
Prerequisites:
- python v3
- python modules: jproperties, requests, pandas, pillow, plotly, kaleido
you can install those with pip3:
pip3 install jproperties requests pandas pillow plotly kaleido
python3 export_csv.py <prometheus_url> <dateStart RFC 3339 | unix_timestamp> <dateEnd RFC 3339 | unix_timestamp> <custom_metrics_file_name>
Example of usage:
python3 export_csv.py http://localhost:9090 2022-12-14T10:00:00Z 2022-12-14T11:30:00Z metrics.txt
A new directory named csv/metrics_%Y-%m-%d-%H:%M:%S with the csv files will be generated.
python3 plot.py <csv_directory>
Example of usage:
python3 plot.py csv/metrics_2022-12-14_11:20:20
A new pdf file report.pdf will be generated in directory csv/metrics_%Y-%m-%d-%H:%M:%S
docker-compose down --volumes