Updated on 2025-11-27 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.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    lts:alarmRule:listWordAlarmRule

    List

    -

    -

    -

    -

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. It can be obtained by calling an API or from the console. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

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

Constraints

N/A

Range

N/A

Default Value

N/A

Content-Type

Yes

String

Definition

Message body format. Set this parameter to application/json;charset=utf8.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

keywords_alarm_rules

Array of KeywordsAlarmRuleRespList objects

Definition

Keyword alarm rule ID.

Table 4 KeywordsAlarmRuleRespList

Parameter

Type

Description

projectId

String

Definition

Project ID.

Range

N/A

keywords_alarm_rule_id

String

Definition

Keyword alarm rule ID.

Range

N/A

keywords_alarm_rule_name

String

Definition

Keyword alarm rule name.

Range

N/A

keywords_alarm_rule_description

String

Definition

Brief description of a keyword alarm rule.

Range

N/A

condition_expression

String

Definition

Alarm condition expression.

Range

N/A

keywords_requests

Array of KeywordsRequestResponse objects

Definition

Keyword alarm rule information.

frequency

FrequencyRespBody object

Definition

Keyword alarm query frequency.

Constraints

N/A

keywords_alarm_level

String

Definition

Keyword alarm severity.

Range

  • Info

  • Minor

  • Major

  • Critical

domain_id

String

Definition

Account ID. For details about how to obtain it, see Obtaining an Account ID.

Range

N/A

create_time

Long

Definition

Creation time (timestamp in milliseconds).

Range

N/A

update_time

Long

Definition

Update time (timestamp in milliseconds).

Range

N/A

status

String

Definition

Keyword alarm status.

Range

  • RUNNING (enabled)

  • STOPPING (disabled)

trigger_condition_count

Integer

Definition

Alarm triggering condition: number of times the condition is met.

Range

N/A

trigger_condition_frequency

Integer

Definition

Alarm triggering condition: number of queries.

Range

N/A

whether_recovery_policy

Boolean

Definition

Whether to configure an alarm restoration policy.

Range

  • true: configures an alarm restoration policy.

  • false: does not configure an alarm restoration policy.

recovery_policy

Integer

Definition

Number of consecutive queries in which the alarm's trigger condition must not be met.

Range

  • Minimum value: 1

  • Maximum value: 10

notification_frequency

Integer

Definition

Keyword alarm notification frequency, in minutes.

Range

0, 5, 10, 15, 30, 60, 180, or 360

alarm_action_rule_name

String

Definition

Alarm action rule name.

Range

N/A

tags

Array of tagsResBody objects

Definition

Alarm tag information. A tag is a key-value pair. Each key is paired with its corresponding value.

Table 5 KeywordsRequestResponse

Parameter

Type

Description

log_stream_id

String

Definition

Log stream ID. For details about how to obtain it, see Obtaining Log Group and Log Stream IDs.

Range

N/A

log_stream_name

String

Definition

Log stream name.

Range

N/A

log_group_id

String

Definition

Log stream ID.

Range

N/A

log_group_name

String

Definition

Log group name.

Range

N/A

keywords

String

Definition

Keyword that can be found in logs.

Range

N/A

condition

String

Definition

Alarm query condition.

Range

<, - >, <=, >=

number

Integer

Definition

Number of matched alarms.

Range

N/A

search_time_range

Integer

Definition

Time range for querying the latest data when an alarm task is executed.

Range

  • Minimum value: 1

  • Maximum value: 60

search_time_range_unit

String

Definition

Unit of the alarm query time range.

Range

  • minute

  • hour

custom_date

CustomDate object

Definition

Customize the alarm query time range based on the time relative to the alarm rule's execution time.

Constraints

N/A

is_time_range_relative

Boolean

Definition

Whether the alarm rule queries logs using a relative time range or an absolute (exact) hour.

Constraints

N/A

Range

  • true: relative time

  • false: exact hour

Default Value

true

Table 6 CustomDate

Parameter

Type

Description

start

Integer

Definition

Value of the offset of the query start time relative to the planned alarm rule execution time.

Constraints

The valid value range for the start field is determined by the start_unit field. The total time converted from the start value and start_unit cannot exceed one day.

Range

If start_unit is set to second, the value of start ranges from 1 to 86400.

If start_unit is set to minute, the value of start ranges from 1 to 1440.

If start_unit is set to hour, the value of start ranges from 1 to 24.

Default Value

  • None

start_unit

String

Definition

Unit of the offset of the query start time relative to the planned alarm rule execution time.

Constraints

When is_time_range_relative is set to false, start_unit cannot be set to second.

Range

  • hour

  • minute

  • second

Default Value

minute

end

Integer

Definition

Value of the offset of the query end time relative to the planned alarm rule execution time.

Constraints

The valid value range for the end field is determined by the start_unit field. The total time converted from the end value and end_unit cannot exceed one day.

Range

If end_unit is set to second, the value of end ranges from 0 to 86399.

If end_unit is set to minute, the value of end ranges from 0 to 1439.

If end_unit is set to hour, the value of end ranges from 0 to 23.

Default Value

  • None

end_unit

String

Definition

Unit of the offset of the query end time relative to the planned alarm rule execution time.

Constraints

When is_time_range_relative is set to false, end_unit cannot be set to second.

Range

  • hour

  • minute

  • second

Default Value

minute

Table 7 FrequencyRespBody

Parameter

Type

Description

type

String

Definition

Query frequency type of alarms.

Range

  • CRON: cron expression

  • HOURLY: every hour

  • DAILY: every day

  • WEEKLY: every week

  • FIXED_RATE: fixed interval

cron_expr

String

Definition

Cron expression. This parameter is returned when type is set to CRON. Cron expressions use the 24-hour format and are precise down to the minute.

Range

N/A

hour_of_day

Integer

Definition

Every hour of every day. This parameter is returned when type is set to DAILY or HOURLY.

Range

N/A

day_of_week

Integer

Definition

Weekly. This parameter is returned when type is set to WEEKLY.

Range

N/A

fixed_rate

Integer

Definition

Fixed interval. This parameter is returned when type is set to FIXED_RATE.

Range

N/A

fixed_rate_unit

String

Definition

Unit of the fixed interval.

Range

  • minute

  • hour

Table 8 tagsResBody

Parameter

Type

Description

key

String

Definition

Tag key.

Range

N/A

value

String

Definition

Tag value.

Range

N/A

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Example Requests

Query 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",
    "domain_id" : "string",
    "create_time" : 0,
    "update_time" : 0,
    "status" : "RUNNING",
    "trigger_condition_count" : "1",
    "trigger_condition_frequency" : "1",
    "whether_recovery_policy" : false,
    "recovery_policy" : "3",
    "notification_frequency" : 5,
    "alarm_action_rule_name" : ""
  } ]
}

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.