Updated on 2024-04-15 GMT+08:00

Reporting Events and Alarms

Function

This API is used to report events and alarms of a user.

URI

PUT /v2/{project_id}/push/events

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

action

No

String

Requested action. clear: The alarm is to be cleared. If this parameter is not transferred or other values are transferred, the alarm is reported by default.

Enumeration values:

  • clear

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM.

Content-Type

Yes

String

Content type, which is application/json.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

events

Yes

Array of EventModel objects

Event or alarm details.

Table 5 EventModel

Parameter

Mandatory

Type

Description

starts_at

No

Long

Time when an event or alarm is generated (CST timestamp precise down to the millisecond).

ends_at

No

Long

Time when an event or alarm is cleared (CST timestamp precise down to the millisecond). 0: The event or alarm is not deleted.

timeout

No

Long

Duration at which an alarm is automatically cleared. Unit: ms. For example, if the duration is 1 minute, set this parameter to 60000. The default value is 3 days (that is, 3 days x 24 hours x 60 minutes x 60s x 1000 ms = 259,200,000 ms).

metadata

No

Map<String,String>

Details of an event or alarm. The value is a key-value pair. A maximum of 30 sub-fields can be extended. The following fields are mandatory: - event_name: event or alarm name, which is a string. - event_severity: event severity, which is an enumerated value with string elements. Options: Critical, Major, Minor, and Info. - event_type: type, which is an enumerated value with string elements. Options: event and alarm. - resource_provider: name of the cloud service corresponding to an event, which is a string. - resource_type: resource type corresponding to an event, which is a string. - resource_id: resource information corresponding to the event, which is a string.

annotations

No

Map<String,String>

Additional field for an event or alarm, which can be left blank.

id

No

String

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

Response Parameters

None

Example Requests

Report an alarm named "test".

PUT https://{EndPoint}/v2/{project_id}/push/events

{
  "events" : [ {
    "starts_at" : 1579420868000,
    "ends_at" : 1579420868000,
    "timeout" : 60000,
    "metadata" : {
      "event_name" : "test",
      "event_severity" : "Major",
      "event_type" : "alarm",
      "resource_provider" : "ecs",
      "resource_type" : "vm",
      "resource_id" : "ecs123"
    },
    "annotations" : {
      "alarm_probableCause_zh_cn" : "possible cause",
      "alarm_fix_suggestion_zh_cn" : "fix suggestion",
      "message" : "details"
    }
  } ]
}

Example Responses

None

Status Codes

Status Code

Description

204

OK

The request is successful.

400

Bad Request

The request is invalid. The client should not repeat the request without modifications.

401

Unauthorized

The authentication information is incorrect or invalid.

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.

500

Internal Server Error

The server is able to receive the request but unable to understand the request.

503

Service Unavailable

The requested service is invalid. The client should not repeat the request without modifications.

Error Codes

See Error Codes.