Updated on 2023-08-08 GMT+08:00

Obtaining Node Alarms

Description

This API is used to generate alarms according to the built-in alarm rules.

URI

POST /v1/{project_id}/node-provider/nodes/{node_id}/alarms/{alert_type}

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Minimum length: 32 characters

Maximum length: 32 characters

node_id

Yes

String

Node ID.

Minimum length: 36 characters

Maximum length: 45 characters

alert_type

Yes

String

Query type. active_alert indicates that active alarms are queried and history_alert indicates that historical alarms are queried.

Minimum length: 1 character

Maximum length: 15 characters

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Minimum length: 1 character

Maximum length: 65,535 characters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

time_range

Yes

String

Time range specified to query data of the last N minutes when the client time is inconsistent with the server time. It can also be used to accurately query data in a specified period. For example, -1.-1.30 indicates the latest 30 minutes.

Minimum length: 0 characters

Maximum length: 100 characters

sort

No

Sort object

Sorting mode of the list.

Table 4 Sort

Parameter

Mandatory

Type

Description

order_by

No

Array of strings

List of sorted fields.

order

No

String

Sorting order, which can be asc (ascending order) or desc (descending order).

Minimum length: 0 characters

Maximum length: 100 characters

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

data

Array of AlarmInfo objects

Alarm list.

count

Integer

Number of records.

Minimum value: 0

Maximum value: 1000

Table 6 AlarmInfo

Parameter

Type

Description

id

String

Event or alarm ID, which is automatically generated by the system.

Minimum length: 0 characters

Maximum length: 100 characters

starts_at

Integer

Time when an event or alarm is generated. The value is a CST timestamp precise down to the millisecond.

Minimum value: 0

Maximum value: 18,446,744,073,709,551,616

ends_at

Integer

Time when an event or alarm is cleared. The value is a CST timestamp precise down to the millisecond. If the value is 0, the event or alarm is not deleted.

Minimum value: 0

Maximum value: 18,446,744,073,709,551,616

timeout

Integer

Duration at which an alarm is automatically cleared, in millisecond. For example, if the duration is one minute, set this parameter to 60,000. The default value is 3 days, that is, 3 days x 24 hours x 60 minutes x 1000 ms = 4,320,000 ms.

Minimum value: 0

Maximum value: 18,446,744,073,709,551,616

metadata

Object

Detailed information about an event or alarm.

annotations

Object

Alarm details.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

code

String

Status code.

Minimum length: 3 characters

Maximum length: 3 characters

error_code

String

Error code.

Minimum length: 12 characters

Maximum length: 12 characters

error_msg

String

Error message.

Minimum length: 1 character

Maximum length: 65,535 characters

message

String

Error details.

Minimum length: 0 characters

Maximum length: 65,535 characters

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

code

String

Status code.

Minimum length: 3 characters

Maximum length: 3 characters

error_code

String

Error code.

Minimum length: 12 characters

Maximum length: 12 characters

error_msg

String

Error message.

Minimum length: 1 character

Maximum length: 65,535 characters

message

String

Error details.

Minimum length: 0 characters

Maximum length: 65,535 characters

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

code

String

Status code.

Minimum length: 3 characters

Maximum length: 3 characters

error_code

String

Error code.

Minimum length: 12 characters

Maximum length: 12 characters

error_msg

String

Error message.

Minimum length: 1 character

Maximum length: 65,535 characters

message

String

Error details.

Minimum length: 0 characters

Maximum length: 65,535 characters

Example Request

{
  "time_range" : "-1.-1.30",
  "sort" : {
    "order_by" : [ "starts_at" ],
    "order" : "desc"
  }
}

Example Response

Status code: 200

Request successful.

{
  "data" : [ {
    "id" : "3512004942693961460",
    "starts_at" : 1671518362723,
    "ends_at" : 1671518362723,
    "timeout" : 1440000,
    "metadata" : "string",
    "annotations" : "string"
  } ],
  "count" : 1
}

Status code: 400

Verify parameter failed.

{
  "code" : 400,
  "error_code" : "BCS.03400001",
  "error_msg" : "Invalid request.",
  "message" : "unmarshal request data error"
}

Status code: 401

Authentication failed.

{
  "code" : 401,
  "error_code" : "BCS.03401001",
  "error_msg" : "Authorization failed.",
  "message" : "request token is not valid"
}

Status code: 500

Internal service error.

{
  "code" : 500,
  "error_code" : "BCS.03500001",
  "error_msg" : "Internal error.",
  "message" : "project [xxx] node [xxx] get service bearer user token error"
}

Status Code

Status Code

Description

200

Request successful.

400

Verify parameter failed.

401

Authentication failed.

500

Internal service error.

Error Code

For details, see Error Codes.