Querying Expression Calculation Results in a Specified Period Using the GET Method
Function
This API is used to query the calculation results of a PromQL expression in a specified period using the GET method.
Calling Method
For details, see Calling APIs.
URI
GET /v1/{project_id}/aom/api/v1/query_range
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID, which can be obtained from the console or by calling an API. For details, see Obtaining a Project ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
query |
Yes |
String |
PromQL expression. For details, see Prometheus official document. |
start |
Yes |
String |
Start timestamp (Unix, in seconds). Example: 2024-10-16 16:03:01 needs to be converted to Unix timestamp 1729065781 using a tool. |
end |
Yes |
String |
End timestamp (Unix, in seconds). Example: 2024-10-16 16:03:01 needs to be converted to Unix timestamp 1729065781 using a tool. |
step |
Yes |
String |
Query step, which indicates a query interval. By setting a step, the time range can be divided into multiple segments. Then calculation is performed for each segment. The step must match the data collection interval to ensure accurate and consistent data. If the step is too small, query performance may deteriorate. If the step is too large, some details may be missed. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. For details, see Obtaining a Token. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
status |
String |
Response status. |
data |
Object |
Response data. |
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
Example Responses
Status code: 200
OK: The request is successful.
{ "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" ] ] } ] } }
Status code: 400
Bad Request: The request is invalid. The client should not repeat the request without modifications.
1:1: parse error: unexpected <op:*>
Status code: 403
Forbidden: The request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications.
{ "status" : "error", "errorType" : "auth", "error" : "auth project_id not pass." }
Status code: 422
Unprocessable: The expression cannot be executed.
{ "status" : "error", "errorType" : "excution", "error" : "expression can't be executed." }
Status code: 503
Service Unavailable: 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 |
OK: The request is successful. |
400 |
Bad Request: The request is invalid. The client should not repeat the request without modifications. |
403 |
Forbidden: The request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications. |
422 |
Unprocessable: The expression cannot be executed. |
503 |
Service Unavailable: 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