Skip to content

Latest commit

 

History

History

prometheus_query_to_csv

Prometheus Query to CSV

Author: Kalibh Halford

This script collects data from Prometheus and writes it to a CSV file.
- It will correctly format data from **openstack** and **node** query variables (e.g.`openstack_nova_vcpus_used`).
- It uses a time range to query over a period of time. The time is required to be in UNIX Epoch format (e.g. `1710770960`).
- You may need to adjust with the step (seconds) in the RawData class init as sometimes you will be querying at an interval where there is no data. This is avoidable by using a very small step. However, that can return duplicated results.
- If you are querying a large amount of data, you may need to increase the amount of RAM allocated to Python. Pagination could be introduced into the script, but it's out of scope for this small use case.
- The default endpoint for a Prometheus host is: `http://:9090/api/v1/query_range`
- The script will make a csv file for each query variable in the same directory as itself in the format (Date Time Hostname Value).