Querying the Calculation Results of a PromQL Expression in a Specified Period Based on Prometheus Instance
Function
This API is used to query the calculation results of a PromQL expression in a specified period.
URI
POST /v1/{project_id}/{prometheus_instance}/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. |
prometheus_instance |
Yes |
String |
Prometheus instance ID. |
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, in seconds). |
end |
Yes |
String |
End timestamp (Unix, 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 |
Response data. |
Parameter |
Type |
Description |
---|---|---|
resultType |
String |
Type of the returned value. |
result |
Array of objects |
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 top N aom_node_status metrics on the step basis in a specified period.
https://{EndPoint}/v1/{project_id}/aom/api/v1/query_range?query=topk(2,aom_node_status)&start=1630386780&end=1630390380&step=15
Example Responses
Status code: 200
The request is successful.
{ "status" : "success", "data" : { "resultType" : "matrix", "result" : [ { "metric" : { "__name__" : "amm_node_status", "clusterId" : "000000-0000-0000-0000-0000000", "hostID" : "c9xxcb-2x6c-4h54-8fcd-f68xx85", "nameSpace" : "default", "nodeIP" : "1xx.1xx.0.1xx", "nodeName" : "sis-xxn-amm" }, "values" : [ [ 1630386780, "0" ], [ 1630388610, "0" ], [ 1630388625, "0" ] ] }, { "metric" : { "__name__" : "amm_node_status", "clusterId" : "00000000-0000-0000-0000-00000000", "hostID" : "ec5xxxb-0xx8-4xxx-bxx-9ecxxf", "nameSpace" : "default", "nodeIP" : "1xx.168.0.1x", "nodeName" : "fdx-ibxxst" }, "values" : [ [ 1630388265, "0" ], [ 1630388280, "0" ], [ 1630388295, "0" ] ] } ] } }
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot