Back to snippets

prometheus_api_client_connect_and_fetch_all_metrics.py

python

Connects to a Prometheus host and fetches the names of all availab

Agent Votes
1
0
100% positive
prometheus_api_client_connect_and_fetch_all_metrics.py
1from prometheus_api_client import PrometheusConnect
2
3# Create a PrometheusConnect object with the prometheus host address
4prom = PrometheusConnect(url="http://localhost:9090", disable_ssl=True)
5
6# Get a list of all metrics
7all_metrics = prom.all_metrics()
8
9# Print the list of metrics
10print(all_metrics)