Querying a Message Template
Function
This API is used to query details about a single message notification template, including its name, content, and creation time. The query provides precise data support for template management.
Calling Method
For details, see Calling APIs.
URI
GET /v2/{project_id}/{domain_id}/lts/events/notification/template/{template_name}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Parameter description: Project ID. For details about how to obtain it, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Constraints: N/A. Value range: N/A. Default value: N/A. |
domain_id |
Yes |
String |
Parameter description: Account ID. For details about how to obtain it, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Constraints: N/A. Value range: N/A. Default value: N/A. |
template_name |
Yes |
String |
Parameter description: Name of the message template to be obtained. Constraints: N/A. Value range: N/A. Default value: N/A. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Parameter description: User token obtained from IAM. For details about how to obtain it, see Obtaining a User Token. Constraints: N/A. Value range: N/A. Default value: N/A. |
Content-Type |
Yes |
String |
Parameter description: Set this parameter to application/json;charset=UTF-8. Constraints: N/A. Value range: N/A. Default value: N/A. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
name |
String |
Parameter description: Notification rule name, which is mandatory. Value range: Enter 1 to 100 characters, including only digits, letters, underscores (_), and hyphens (-). Do not start or end with a special character such as an underscore. This value cannot be modified after creation. |
type |
Array of strings |
Parameter description: This field is reserved and optional. Value range: N/A. |
desc |
String |
Parameter description: Template description, which is optional. Value range: Enter up to 1,024 characters, including only digits, letters, and underscores (_). Do not start or end with an underscore. |
source |
String |
Parameter description: Template source. Value range: Currently, this parameter must be set to LTS. Otherwise, templates cannot be filtered. |
templates |
Array of SubTemplateResBody objects |
Parameter description: Template body, which is an array. Value range: N/A. |
locale |
String |
Parameter description: Local language code. Value range: N/A. |
create_time |
Long |
Parameter description: Creation time (timestamp in milliseconds). Value range: N/A. |
modify_time |
Long |
Parameter description: Update time (timestamp in milliseconds). Value range: N/A. |
project_id |
String |
Parameter description: Project ID. For details about how to obtain it, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID. Value range: N/A. |
Parameter |
Type |
Description |
---|---|---|
sub_type |
String |
Parameter description: Template subtype. The following types are supported: sms, dingding (DingTalk), wechat (WeCom), webhook, and email. Value range: N/A. |
content |
String |
Parameter description: Sub-template body. A variable following a dollar sign ($) can only be one of the following variables. The supported variables vary according to alarm types (keyword or SQL). Currently, the two alarm types have the following common variables: Alarm severity: ${event_severity}; Occurrence time: ${starts_at}; Alarm source: $event.metadata.resource_provider; Resource type: $event.metadata.resource_type; Resource ID: ${resources}; Statistical type: by keyword; Expression: $event.annotations.condition_expression; Current value: $event.annotations.current_value; Statistical period: $event.annotations.frequency; Variables specific to keyword alarms: Query time: $event.annotations.results[0].time; Query log: $event.annotations.results[0].raw_results; Variables specific to SQL alarms: Log group/stream name: $event.annotations.results[0].resource_id; Query statement: $event.annotations.results[0].sql; Query time: $event.annotations.results[0].time; Query URL: $event.annotations.results[0].url; Query log: $event.annotations.results[0].raw_results; Alarm severity: ${event_severity}; Occurrence time: ${starts_at}; Alarm source: $event.metadata.resource_provider; Resource type: $event.metadata.resource_type; Resource ID: ${resources}; Statistical type: by keyword; Expression: $event.annotations.condition_expression; Current value: $event.annotations.current_value; Statistical period: $event.annotations.frequency; Variables specific to keyword alarms: Query time: $event.annotations.results[0].time; Query log: $event.annotations.results[0].raw_results; Variables specific to SQL alarms: Log group/stream name: $event.annotations.results[0].resource_id; Query statement: $event.annotations.results[0].sql; Query time: $event.annotations.results[0].time; Query URL: $event.annotations.results[0].url; Query log: $event.annotations.results[0].raw_results;
Each variable must be followed by an English semicolon (;). Otherwise, the template replacement fails.
Value range: N/A. |
topic |
String |
Parameter description: Email subject. This parameter is valid only when sub_type is set to email. Value range: N/A. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Parameter description: Error code. Value range: N/A. |
error_msg |
String |
Parameter description: Error message. Value range: N/A. |
Example Requests
Query a message template with a specified name.
GET https://{endpoint}/v2/{project_id}/{domain_id}/lts/events/notification/template/{template_name} /v2/{project_id}/{domain_id}/lts/events/notification/template/{template_name}
Example Responses
Status code: 200
The request is successful.
{
"create_time" : 1702955600631,
"desc" : "description",
"locale" : "zh-cn",
"modify_time" : 1702955600631,
"name" : "postman-test",
"project_id" : "2a473356cca5487f8373be891bffc1cf",
"source" : "LTS",
"templates" : [ {
"content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
"sub_type" : "sms"
}, {
"content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
"sub_type" : "dingding"
}, {
"content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
"sub_type" : "wechat"
}, {
"content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
"sub_type" : "webhook"
}, {
"content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nAlarm source: $event.metadata.resource_provider;\nResource type: $event.metadata.resource_type;\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;\nQuery time: $event.annotations.results[0].time;\nQuery log: $event.annotations.results[0].raw_results;",
"sub_type" : "email"
}, {
"content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
"sub_type" : "voice"
} ],
"type" : [ ]
}
Status code: 500
The server has received the request but encountered an internal error.
{
"error_code" : "LTS.2018",
"error_msg" : "Failed to get notification template."
}
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot