When constructing API requests, ensure you replace
<prometheus_server> with the actual address of your Prometheus instance.Basic Query Execution
To query metrics, send a POST request to the following URL on your Prometheus server:http://<prometheus_server>:9090/api/v1/query
The PromQL query is provided via the query parameter. For example, to retrieve the number of ARP entries on a specific node filtered by the instance label, execute:
Querying Metrics at a Specific Time
If you require the metric value at a specific point in time rather than the most recent one, add an additionaltime parameter to your request. For example, to obtain node_arp_entries for a particular node at Unix timestamp 1670380680.132, use:
Retrieving a Range Vector
To examine time-series data over a defined duration (for example, the last 10 minutes), incorporate a range vector selector into your query. The following example retrieves time series data fornode_memory_Active_bytes associated with the job="node" label over the previous 10 minutes:
Summary of Example Queries
Below is a progression of Prometheus HTTP API queries that demonstrate different use cases:1. Basic Metric Query
Retrieve the latest value for a metric:2. Query at a Specific Time
To query a metric likenode_memory_Active_bytes at a specific point in time:
3. Range Vector Query
To retrieve a range vector with data points over a specified period (e.g., the past 10 minutes):Always verify your queries and parameters to match your Prometheus server configuration. This ensures accurate and efficient retrieval of the metrics you need.