Querying Expression Calculation Results in a Specified Period
Function
This API is used to query the calculation results of a PromQL expression in a specified period. (This API is available in CN North-Beijing 4, CN East-Shanghai 1, and CN South-Guangzhou.)
URI
GET /v1/{project_id}/aom/api/v1/query_range
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| query | Yes | String | PromQL expression. For details, see https://prometheus.io/docs/prometheus/latest/querying/basics/. |
| start | Yes | String | Start timestamp (Unix timestamp, in seconds). |
| end | Yes | String | End timestamp (Unix timestamp, in seconds). |
| step | Yes | String | Query step (in seconds). The task is executed on the step basis within the specified period. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | User token obtained from IAM. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| status | String | Response status. |
| data | Data object | Data details. |
| Parameter | Type | Description |
|---|---|---|
| resultType | String | Type of the returned value. |
| result | Array of strings | Data information. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| status | String | Response status. |
| errorType | String | Error type. |
| error | String | Error message. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| status | String | Response status. |
| errorType | String | Error type. |
| error | String | Error message. |
Status code: 422
| Parameter | Type | Description |
|---|---|---|
| status | String | Response status. |
| errorType | String | Error type. |
| error | String | Error message. |
Status code: 503
| Parameter | Type | Description |
|---|---|---|
| status | String | Response status. |
| errorType | String | Error type. |
| error | String | Error message. |
Example Requests
Query the calculation result of PromQL expression "up" every 15s in a specified period.
https://{EndPoint}/v1/{project_id}/aom/api/v1/query_range?query=up&start=1630124012&end=1630127612&step=15s
{
"status" : "success",
"data" : {
"resultType" : "matrix",
"result" : [ {
"metric" : {
"__name__" : "up",
"job" : "prometheus",
"instance" : "localhost:9090"
},
"values" : [ [ 1.435781430781E9, "1" ], [ 1.435781445781E9, "1" ], [ 1.435781460781E9, "1" ] ]
}, {
"metric" : {
"__name__" : "up",
"job" : "node",
"instance" : "localhost:9091"
},
"values" : [ [ 1.435781430781E9, "0" ], [ 1.435781445781E9, "0" ], [ 1.435781460781E9, "1" ] ]
} ]
}
} Example Responses
Status code: 200
The request is successful.
"{\n \"status\": \"success\" ,\n \"data\": <data>\n}" Status code: 400
Invalid request. Parameters are incorrect or missing. The client should not repeat the request without modifications.
{
"status" : "error",
"errorType" : "bad_param",
"error" : "param is invalid."
} Status code: 403
Access denied.
{
"status" : "error",
"errorType" : "auth",
"error" : "auth project_id not pass."
} Status code: 422
The expression cannot be executed.
{
"status" : "error",
"errorType" : "excution",
"error" : "expression can't be executed."
} Status code: 503
The requested service is invalid. The client should not repeat the request without modifications.
{
"status" : "error",
"errorType" : "timeout",
"error" : "query timed out in query execution."
} Status Codes
| Status Code | Description |
|---|---|
| 200 | The request is successful. |
| 400 | Invalid request. Parameters are incorrect or missing. The client should not repeat the request without modifications. |
| 403 | Access denied. |
| 422 | The expression cannot be executed. |
| 503 | The requested service is invalid. The client should not repeat the request without modifications. |
Error Codes
See Error Codes.
Last Article: Prometheus Monitoring
Next Article: Querying Expression Calculation Results in a Specified Period
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.