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?
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.
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.
To use Prometheus's built-in expression browser, navigate to http://localhost:9090/graph and choose the "Table" view within the "Graph" tab.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With