Updated on 2024-01-16 GMT+08:00

Querying a Keyword Alarm Rule

Function

This API is used to query a keyword alarm.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/lts/alarms/keywords-alarm-rule

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Default: None

Minimum: 32

Maximum: 32

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Default: None

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Default: None

Minimum: 30

Maximum: 30

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

keywords_alarm_rules

Array of KeywordsAlarmRuleRespList objects

Project ID.

Table 4 KeywordsAlarmRuleRespList

Parameter

Type

Description

projectId

String

Project ID.

Minimum: 32

Maximum: 32

keywords_alarm_rule_id

String

Keyword alarm ID.

Minimum: 36

Maximum: 36

keywords_alarm_rule_name

String

Keyword alarm names.

Minimum: 1

Maximum: 64

keywords_alarm_rule_description

String

Keyword alarm description.

Minimum: 0

Maximum: 64

condition_expression

String

Condition.

Minimum: 0

Maximum: 64

keywords_requests

Array of KeywordsRequest objects

Keyword details.

frequency

Frequency object

Alarm statistical period.

keywords_alarm_level

String

Alarm severity.

Enumeration values:

  • Info

  • Minor

  • Major

  • Critical

keywords_alarm_send

Boolean

Whether to send an alarm.

domain_id

String

domainId

Minimum: 32

Maximum: 32

create_time

Long

Creation time (timestamp in milliseconds).

Minimum: 13

Maximum: 13

update_time

Long

Update time (timestamp in milliseconds).

Minimum: 13

Maximum: 13

topics

Array of Topics objects

Topic.

template_name

String

Message template name.

status

String

Alarm status.

Enumeration values:

  • RUNNING: enabled

  • STOPPING: disabled

trigger_condition_count

Integer

Trigger condition. The number of triggering periods is 1 by default.

trigger_condition_frequency

Integer

Trigger condition. The number of triggering times is 1 by default.

whether_recovery_policy

Boolean

Indicates whether to enable the recovery notification. The default value is false.

recovery_policy

Integer

The recovery policy period is 3 by default.

notification_frequency

Integer

Notification frequency, in minutes.

Enumeration values:

  • 0

  • 5

  • 10

  • 15

  • 30

  • 60

  • 180

  • 360

alarm_action_rule_name

String

Alarm action rule name.

NOTE:

Set alarm_action_rule_name or notification_save_rule. If you set both of them, the value of alarm_action_rule_name is prioritized.

Table 5 KeywordsRequest

Parameter

Type

Description

log_stream_id

String

Log stream ID.

Minimum: 36

Maximum: 36

log_stream_name

String

Log stream name.

Minimum: 1

Maximum: 64

log_group_id

String

Log group ID.

Minimum: 36

Maximum: 36

log_group_name

String

Log group name.

Minimum: 1

Maximum: 64

keywords

String

Keyword

Minimum: 1

Maximum: 1024

condition

String

Condition

Enumeration values:

  • >=

  • <=

  • <

  • >

number

Integer

Row

Minimum: 1

Maximum: 2147483647

search_time_range

Integer

Time range for querying the latest data when a task is executed. The maximum value is 60 and the minimum is 1 if the unit is minute. The maximum is 24 and the minimum is 1 if the unit is hour.

search_time_range_unit

String

Query time unit.

Enumeration values:

  • minute

Table 6 Frequency

Parameter

Type

Description

type

String

Time type.

Enumeration values:

  • CRON

  • HOURLY

  • DAILY

  • WEEKLY

  • FIXED_RATE

cron_expr

String

This field is used when type is set to CRON.

Minimum: 1

Maximum: 1024

hour_of_day

Integer

This field is used when type is set to DAILY or WEEKLY. DAILY ranges from 0 to 23. WEEKLY ranges from 0 to 23.

day_of_week

Integer

This field is used when type is set to WEEKLY (Sunday to Saturday).

Minimum: 1

Maximum: 7

fixed_rate

Integer

This field is used when type is set to FIXED_RATE. If the unit of fixed_rate_unit is minute, the maximum value is 60. If the unit is hour, the value ranges from 5 to 24.

Minimum: 1

Maximum: 60

fixed_rate_unit

String

Time unit.

Enumeration values:

  • minute

  • hour

Table 7 Topics

Parameter

Type

Description

name

String

Topic name.

Minimum: 1

Maximum: 1024

topic_urn

String

Specifies the resource identifier of the topic, which is unique.

Minimum: 1

Maximum: 1024

display_name

String

Specifies the topic display name, which is presented as the name of the email sender in email messages.

Minimum: 1

Maximum: 1024

push_policy

Integer

Specifies the message push policy.

Minimum: 1

Maximum: 1024

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Enumeration values:

  • Invalid projectId

Example Requests

Querying a keyword alarm rule

GET https://{endpoint}/v2/{project_id}/lts/alarms/keywords-alarm-rule

/v2/{project_id}/lts/alarms/keywords-alarm-rule

Example Responses

Status code: 200

The request is successful.

{
  "keywords_alarm_rules" : [ {
    "projectId" : "string",
    "keywords_alarm_rule_id" : "string",
    "keywords_alarm_rule_name" : "string",
    "keywords_alarm_rule_description" : "string",
    "condition_expression" : "string",
    "keywords_requests" : [ {
      "log_stream_id" : "string",
      "log_stream_name" : "string",
      "log_group_id" : "string",
      "log_group_name" : "string",
      "keywords" : "string",
      "condition" : ">=",
      "number" : 1,
      "search_time_range" : 0,
      "search_time_range_unit" : "minute"
    } ],
    "frequency" : {
      "type" : "CRON",
      "cron_expr" : "string",
      "hour_of_day" : 0,
      "day_of_week" : 0,
      "fixed_rate" : 0,
      "fixed_rate_unit" : "minute"
    },
    "keywords_alarm_level" : "Info",
    "keywords_alarm_send" : true,
    "domain_id" : "string",
    "create_time" : 0,
    "update_time" : 0,
    "template_name" : "Message template name.",
    "status" : "RUNNING",
    "trigger_condition_count" : "1",
    "trigger_condition_frequency" : "1",
    "whether_recovery_policy" : false,
    "recovery_policy" : "3",
    "notification_frequency" : 5,
    "alarm_action_rule_name" : "",
    "topics" : [ {
      "name" : "string",
      "topic_urn" : "string",
      "display_name" : "string",
      "push_policy" : 0
    } ]
  } ]
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.2008",
  "error_msg" : "Find Alarm rule failed."
}

Status Codes

Status Code

Description

200

The request is successful.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.