Prometheus
Prometheus API Client in Python
When it comes to metrics analyzing, Prometheus is a popular choice. For getting metrics from Prometheus we can use its HTTP API. Consider this http for getting query range in Prometheus:
For convenience, we can install Python Prometheus API client library.
pip install prometheus-api-client
For example we can get all metrics from prometheus
def print_metrics():
from prometheus_api_client import PrometheusConnect
prom = PrometheusConnect(url="http://3.19.55.237:9090", disable_ssl=True)
# Get the list of all the metrics that the Prometheus host scrapes
print(prom.all_metrics())
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_metrics()
The console will show all the metrics
['CodeGenerator_compilationTime_count', 'CodeGenerator_compilationTime_max', 'CodeGenerator_compilationTime_mean', 'CodeGenerator_compilationTime_min', 'CodeGenerator_compilationTime_p50', 'CodeGenerator_compilationTime_p75', ....
There’s a lot more features so take your time to explore.
Happy coding ~~