Help Center/ Application Operations Management/ API Reference (Ankara Region)/ APIs/ Prometheus Monitoring/ Querying the Expression Calculation Result at a Specified Time Point
Updated on 2024-04-15 GMT+08:00

Querying the Expression Calculation Result at a Specified Time Point

Function

This API is used to query the calculation result of a PromQL expression at a specified time point.

URI

POST /v1/{project_id}/aom/api/v1/query

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID obtained from IAM. Generally, a project ID contains 32 characters.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

query

Yes

String

PromQL expression. For details, see https://prometheus.io/docs/prometheus/latest/querying/basics/.

time

No

String

Timestamp specified for PromQL calculation (Unix timestamp, in seconds).

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

status

String

Response status.

data

Data object

Response data.

Table 5 Data

Parameter

Type

Description

resultType

String

Type of the returned value.

result

Array of objects

Data information.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

status

String

Response status.

errorType

String

Error type.

error

String

Error message.

Status code: 403

Table 7 Response body parameters

Parameter

Type

Description

status

String

Response status.

errorType

String

Error type.

error

String

Error message.

Status code: 422

Table 8 Response body parameters

Parameter

Type

Description

status

String

Response status.

errorType

String

Error type.

error

String

Error message.

Status code: 503

Table 9 Response body parameters

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 at time point "1630381536".

https://{EndPoint}/v1/{project_id}/aom/api/v1/query?query=topk(2,aom_node_status)&time=1630381536

Example Responses

Status code: 200

The request is successful.

{
  "status" : "success",
  "data" : {
    "resultType" : "vector",
    "result" : [ {
      "metric" : {
        "__name__" : "amm_node_status",
        "clusterId" : "00000000-0000-0000-0000-00000000",
        "hostID" : "g947xcxh-2xcxc-xxx-xxcd-f6xxx85",
        "nameSpace" : "default",
        "nodeIP" : "1x6.1xx.0.xxx",
        "nodeName" : "sdxx-jxxxgksi-axx"
      },
      "value" : [ 16303810036, "0" ]
    }, {
      "metric" : {
        "__name__" : "amm_node_status",
        "clusterId" : "00000000-0000-0000-0000-00000000",
        "hostID" : "dc1xxxf7e-b095-4e77-bxx-914dhlxxxbf7",
        "nameSpace" : "default",
        "nodeIP" : "1xx.1xx.0.xxx",
        "nodeName" : "sds-jixxxsi-texxt"
      },
      "value" : [ 1630381536, "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.