Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all the metrics of an instance with prometheus api?

I want to fetch the monitor host's metrics through the api of prometheus, and I need to initiate a request for each metric requested.

curl http://IP:9090/api/v1/query?query=node_cpu_seconds_total{instance="IP:9100"}

curl http://IP:9090/api/v1/query?query=node_memory_MemTotal_bytes{instance="IP:9100"}

Is there a way to request all the performance data from the monitoring host at once?

like image 928
deng.zhengyi Avatar asked Aug 20 '20 03:08

deng.zhengyi


People also ask

How do I get Prometheus metrics?

Once Prometheus has a list of endpoints, it can begin to retrieve metrics from them. Prometheus retrieves metrics in a very straightforward manner; a simple HTTP request. The configuration points to a specific location on the endpoint that supplies a stream of text identifying the metric and its current value.

Can Prometheus pull metrics?

Although Prometheus is a primarily pull-based monitoring system, an additional component called the "Pushgateway" is available for pushing metrics from external applications and services. The Pushgateway is useful for collecting metrics from systems that are not compatible with the otherwise pull-based infrastructure.

How do I get Prometheus metrics locally?

To use Prometheus's built-in expression browser, navigate to http://localhost:9090/graph and choose the "Table" view within the "Graph" tab.


Video Answer


1 Answers

You can fetch all metrics with following curl expression:

url=http://{urIPorhostname}:9090    
curl -s  $url/api/v1/label/__name__/values | jq -r ".data[]" | sort 
like image 170
Boris Ivanov Avatar answered Sep 29 '22 07:09

Boris Ivanov