Updated on 2024-12-20 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.

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.

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

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

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.

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.

trigger_condition_count

Integer

Number of queries in which the triggering condition is met. The default value is 1.

trigger_condition_frequency

Integer

Number of times that log events meet the trigger condition. The default value is 1.

whether_recovery_policy

Boolean

Whether to enable the alarm clearance notification. The default value is false.

recovery_policy

Integer

Number of queries in which the triggering condition is not met. The alarm is cleared when this number reaches the value (3 by default) of this parameter.

notification_frequency

Integer

Notification frequency, in minutes.

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

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.

Table 6 Frequency

Parameter

Type

Description

type

String

Time type.

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.

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.

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.