Detailed log:{{.QueryLog[0][0]}}

Detailed log:{"content":{"body_bytes_sent":"33352","http_referer":"-","http_user_agent":"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36","remote_addr":"201.80.83.199","remote_user":"-","request_method":"GET","request_uri":"/content/themes/test-com/images/header_about.jpg","status":"404","time_local":"01/Nov/2018:01:16:31"},"fileName":"/root/testLog/nginx.log","pkg_id":"285A243662909DE3-70A","source":"172.17.0.2","time":1653831150008,"topicId":"a54de372-ffe0-49ae-a12e-c340bb2b03f2"}
Variable | Description | Example Variable Value | Shipped Log | Description |
{{.RecordId}} | Alarm notification ID | 76afb409-4648-xxxx-b67a-fe350129ceb4 | No | Each alarm notification uses a different ID. |
{{.RecordGroupId}} | Alarm group ID | 52746a79-7681-495f-xxxx-2715593e625a | Yes | From alarm trigger to clearance, the ID remains the same regardless of how many notifications are sent. When group-based trigger is enabled in an alarm policy, multiple alarms may be generated simultaneously, each corresponding to a different group and ID. |
{{.UIN}} | Account ID | 100007xxx827 | Yes | - |
{{.Nickname}} | Account nickname. | xx company | Yes | - |
{{.Region}} | Region | Guangzhou Note: Logs are delivered in English, for example, ap-guangzhou. | Yes | - |
{{.Alarm}} | Alarm policy name. | Excessive Nginx error logs | Yes | - |
{{.AlarmID}} | Alarm policy ID. | notice-3abd7ad6-15b7-4168-xxxx-52e5b961a561 | Yes | - |
{{.Topic}} | Log Topic Name | nginxLog | Yes | - |
{{.TopicId}} | Log topic ID. | a54de372-ffe0-49ae-xxxx-c340bb2b03f2 | Yes | - |
{{.Logset}} | Logset Name | demo_logset | No | - |
{{.LogsetId}} | Logset ID | 1284d7c3-a7e3-4005-xxxx-ef95ca05d02e | Yes | - |
{{.QueryParams}} | Query parameters for the execution statement | [{ "TopicId": "36c6df96-a6ad-xxxx-99ec-3f0b66dea302", "TopicName": "CDN Demo Access Log Topic_10000753xxxx" "TopicType": "log", "Query": "* | select approx_percentile(request_time, 0.99) as p99", "grammarVersion": "cql", "StartTime": 1690956330000, "EndTime": 1690957230000, "QueryUrlPath": "/cls/search?grammarVersion=cql&queryBase64=KiB8IHNlbGVjdCBhcHByb3hfcGVyY2VudGlsZShyZXF1ZXN0X3RpbWUsIDAuOTkpIGFzIHA5OQ%3D%3D®ion=ap-chongqing&time=2023-08-02T14%3A05%3A30.000%2C2023-08-02T14%3A20%3A30.000&topic_id=36c6df96-a6ad-xxxx-99ec-3f0b66dea302" }] | Yes | Array structure. {{.QueryParams[0]}} represents the first execution statement, {{.QueryParams[1]}} represents the second execution statement, and so on. |
{{.Condition}} | Trigger Conditions | $1.errorLogCount > 1 | Yes | - |
{{.ConditionGroup}} | Corresponding group information when the alarm is triggered by group. | {"$1.AppName":"userManageService"} | Yes | This variable is available only when group-based trigger is enabled in the alarm policy. |
{{.Level}} | Alarm level | Info | Yes | Critical Warn Info |
{{.Level_zh}} | Alarm level | Info | No | Emergency Warning Info |
{{.HappenThreshold}} | Number of times that the alarm triggering condition is continuously met. | 1 | Yes | - |
{{.AlertThreshold}} | Alarm interval. | 15 | Yes | Unit: min. |
{{.Label}} | Additional classification field. | {"service":"payService"} | Yes | |
{{.StartTime}} | First alarm triggering time. | 2022-05-28 18:56:37 | Yes | Time zone: Asia/Shanghai |
{{.StartTimeUnix}} | First alarm triggering timestamp. | 1653735397099 | Yes | Unix timestamp in milliseconds |
{{.NotifyTime}} | Notification time of this alarm. | 2022-05-28 19:41:37 | Yes | Time zone: Asia/Shanghai |
{{.NotifyTimeUnix}} | Notification timestamp for this alarm. | 1653738097099 | Yes | Unix timestamp in milliseconds |
{{.NotifyType}} | Alarm notification type. | 1 | Yes | 1: alarm notification 2: clearance notification |
{{.ConsecutiveAlertNums}} | Number of consecutive alarms. | 2 | Yes | - |
{{.Duration}} | Alarm duration. | 0 | Yes | Unit: min. |
{{.DetailUrl}} | Alarm details page URL | https://alarm.cls.tencentcs.com/MDv2xxJh | Yes | No login required |
{{.QueryUrl}} | Search and analysis URL for the first execution statement | https://alarm.cls.tencentcs.com/T0pkxxMA | No | To obtain URLs for other execution statements, use {{.QueryParams}}. |
{{.SilentUrl}} | Alarm blocking URL | https://alarm.cls.tencentcs.com/K6hyxxyG | Yes | No login required. Available only when {{.CanSilent}} is true, for example: {{if .CanSilent}}{{.SilentUrl}}{{end}}. |
{{.CanSilent}} | Whether Direct Alarm Blocking via {{.SilentUrl}} Is Supported | true | Yes | This value is true when the Alarm Operation Without Login feature is enabled in the notification group; otherwise, it is false. |
{{.Message}} | Additional notification content | - | Yes | Indicates the additional notification content specified in the alarm policy configuration. Maximum size: 10 KB. Content exceeding this limit will be automatically truncated. |
{{.TriggerParams}} | Parameters upon alarm triggering. | $1.errorLogCount=5; | Yes | When multiple results of an execution statement meet trigger criteria simultaneously, only the first result is recorded. This variable is available only during alarm trigger instead of alarm clearance. |
{{.QueryResult}} | Statement execution result. | Yes | - | |
{{.TriggerResult}} | Execution statement results meeting trigger criteria | Yes | This variable is available only during alarm trigger instead of alarm clearance. | |
{{.QueryLog}} | Detailed logs matching the search conditions in the execution statement. | Yes | - | |
{{.AnalysisResult}} | Multi-dimensional analysis result. | Yes | This variable is available only during alarm trigger instead of alarm clearance. | |
{{.AnalysisResultFormat}} | Formatted multi-dimensional analysis results | - | No | The content is identical to {{.AnalysisResult}}, but the json is formatted into text, using line breaks, tables, and other forms for presentation to improve readability. |
{{.AnalysisResultFormat_zh}} | Formatted multi-dimensional analysis results | - | No | |
AlarmExecutionStatus | Alarm policy execution result | TriggerNotice.SendSuccess | Yes | Only supports log delivery. |
AlarmExecutionErrorDetail | Alarm policy execution exception details | {"TriggerFailedReason":"Parse expression failed: Invalid token: '$'","notify_result_group":null} | Yes | Only supports log delivery. |
Silent | Whether the current alarm notification is silenced | All notifications are blocked: SilentAll. Some notifications are blocked: SilentPartial. Not blocked: NotSilent. | Yes | Only supports log delivery. |
{{.QueryResult[0]}} represents the execution result of the first execution statement, {{.QueryResult[1]}} represents the execution result of the second execution statement, and so on. Each statement can contain up to 1,000 entries with a maximum size of 10 KB. Up to 10 statements are supported, with a total maximum size of 100 KB. Content exceeding these limits will be automatically truncated.First execution statement: status:>=400 | select count(*) as errorLogCount.Second execution statement: status:>=400 | select count(*) as errorLogCount,request_uri group by request_uri order by count(*) desc.
[[{"errorLogCount": 7}],[{"errorLogCount": 3,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 3,"request_uri": "/feed"}, {"errorLogCount": 1,"request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html"}]]
{{.TriggerResult[0]}} represents the execution result of the first execution statement, {{.TriggerResult[1]}} represents the execution result of the second execution statement, and so on. Each statement can contain up to 1,000 entries with a maximum size of 10 KB. Up to 10 statements are supported, with a total maximum size of 100 KB. Content exceeding these limits will be automatically truncated.$1.errorLogCount > 1, the variable values are as follows:[[{"errorLogCount": 7}],[{"errorLogCount": 3,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 3,"request_uri": "/feed"}]]
{{.QueryLog[0]}} represents the detailed log of the first execution statement, {{.QueryLog[1]}} represents the detailed log of the second execution statement, and so on. Each statement can contain up to 10 entries with a maximum size of 50 KB. Up to 10 statements are supported, with a total maximum size of 150 KB. Content exceeding these limits will be automatically truncated.[[{"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "32847","http_referer": "-","http_user_agent": "Opera/9.80 (Windows NT 6.1; U; en-US) Presto/2.7.62 Version/11.01","remote_addr": "105.86.148.186","remote_user": "-","request_method": "GET","request_uri": "/apple-touch-icon-144x144.png","status": "404","time_local": "01/Nov/2018:00:55:14"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5CD","source": "172.17.0.2","time": 1653739000013,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}, {"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "33496","http_referer": "-","http_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36","remote_addr": "222.18.168.242","remote_user": "-","request_method": "GET","request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html","status": "404","time_local": "01/Nov/2018:00:54:37"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5C8","source": "172.17.0.2","time": 1653738975008,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}]]
{"Detailed Logs": [{"LogParseFailure": "I0911 11:30:28.235387 1 leaderelection.go:273] successfully renewed lease kube-system/external-attacher-leader-com-tencent-cloud-csi-cbs","__FILENAME__": "/var/log/tke-log-agent/test-log9-8/stdout-containerd/csi-cbs-controller-58d8c6f79f-6f48w_kube-system_csi-attacher-100034c83b26d21a6cca51ba53ebc36e81f5e6eec04165478ec3a848d105e042.log","__HOSTNAME__": "VM-0-38-centos","__INDEX_STATUS__": "","__PKG_LOGID__": "7C6A04E2682AF44F-D71A","__SOURCE__": "10.0.0.38","__TAG__.cluster_id": "cls-4mhq30b8","__TAG__.container_id": "100034c83b26d21a6cca51ba53ebc36e81f5e6eec04165478ec3a848d105e042","__TAG__.container_name": "csi-attacher","__TAG__.image_name": "ccr.ccs.tencentyun.com/tkeimages/csi-attacher:v3.0.3","__TAG__.namespace": "kube-system","__TAG__.pod_ip": "10.0.0.32","__TAG__.pod_label_app": "cbs-csi-controller","__TAG__.pod_label_metrics": "cbs-csi-controller","__TAG__.pod_label_pod-template-hash": "58d8c6f79f","__TAG__.pod_name": "csi-cbs-controller-58d8c6f79f-6f48w","__TAG__.pod_uid": "ab4f7b63-2cab-442c-a532-125e767d83ec","__TAG__.stream": "stderr","__TIMESTAMP__": "1757590229046"}]}
Detailed Logs is the name of the multi-dimensional analysis configured in the alarm policy.{"Top URL": [{"count": 77,"ratio": 0.45294117647058824,"value": "/"}, {"count": 20,"ratio": 0.11764705882352941,"value": "/favicon.ico"}, {"count": 7,"ratio": 0.041176470588235294,"value": "/blog/feed"}, {"count": 5,"ratio": 0.029411764705882353,"value": "/test-tile-service"}, {"count": 3,"ratio": 0.01764705882352941,"value": "/android-chrome-192x192.png"}]}
Top URL is the name of the multi-dimensional analysis configured in the alarm policy.{"Detailed error logs": [{"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "32847","http_referer": "-","http_user_agent": "Opera/9.80 (Windows NT 6.1; U; en-US) Presto/2.7.62 Version/11.01","remote_addr": "105.86.148.186","remote_user": "-","request_method": "GET","request_uri": "/apple-touch-icon-144x144.png","status": "404","time_local": "01/Nov/2018:00:55:14"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5CD","source": "172.17.0.2","time": 1653739000013,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}, {"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "33496","http_referer": "-","http_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36","remote_addr": "222.18.168.242","remote_user": "-","request_method": "GET","request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html","status": "404","time_local": "01/Nov/2018:00:54:37"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5C8","source": "172.17.0.2","time": 1653738975008,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}]}
Detailed Error Logs is the name of the multi-dimensional analysis configured in the alarm policy.{"Error log URL distribution": [{"errorLogCount": 3,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 3,"request_uri": "/feed"}, {"errorLogCount": 1,"request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html"}]}
Error Log URL Distribution is the name of the multi-dimensional analysis configured in the alarm policy.{{ }}, and text outside these delimiters will not be processed.{{.variable[x]}} or {{index .variable x}}{{.variable.childNodeName}} or {{index .variable "childNodeName"}}
{{.variable[x]}} to extract the corresponding array element by its index, where x is an integer greater than or equal to 0. This syntax is equivalent to {{index .variable x}}.{{.variable.childNodeKey}} to extract the corresponding child object value by its key. This syntax is equivalent to {{index .variable "childNodeName"}}.$, -, or consists of pure numbers, use the {{index .variable "childNodeName"}} syntax. Examples include {{index .AnalysisResult "Top URL"}}, {{index .ConditionGroup "$1.AppName"}}, and {{index .variable "123"}}.{{.QueryResult}} variable is:[[{"errorLogCount": 7 // Extract this value.}],[{"errorLogCount": 3,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 3,"request_uri": "/feed"}, {"errorLogCount": 1,"request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html"}]]
{{.QueryResult[0][0].errorLogCount}}
7
{{range .variable}}custom_content_{{.childNode1}} custom_content_{{.childNode2}}...{{end}}
{{range $key,$value := .variable}}custom_content_{{$key}} custom_content_{{$value}}...{{end}}
range syntax, elements/objects from within the .variable are obtained by default. You cannot directly use the {{.UIN}} format to obtain external variables. To obtain them, create an independent variable outside the range syntax in advance, for example:{{$UIN := .UIN}} // Create a variable{{range .variable}}custom_content_{{.childNode1}} custom_content_{{.childNode2}}...{{$UIN}} // Use the variable{{end}}
{{.QueryResult}} are as follows:[[{"errorLogCount": 7}],[{"errorLogCount": 3,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 3,"request_uri": "/feed"}, {"errorLogCount": 1,"request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html"}]]
{{range .QueryResult[1]}}* {{.request_uri}} error log count: {{.errorLogCount}}{{end}}
* /apple-touch-icon-144x144.png error log count: 3* /feed error log count: 3* /opt/node_apps/test-v5/app/themes/basic/public/static/404.html error log count: 1
{{if boolen}}xxx{{end}}
{{if boolen}}xxx{{else}}xxx{{end}}
{{if boolen}}xxx{{else if boolen}}xxx{{end}}
eq arg1 arg2: returns true if arg1 == arg2.ne arg1 arg2: returns true if arg1 ! = arg2.lt arg1 arg2: returns true if arg1 < arg2.le arg1 arg2: returns true if arg1 <= arg2.gt arg1 arg2: returns true if arg1 > arg2.ge arg1 arg2: returns true if arg1 >= arg2.
{{.QueryResult}} are as follows:[[{"errorLogCount": 7}],[{"errorLogCount": 3,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 3,"request_uri": "/feed"}, {"errorLogCount": 1,"request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html"}]]
{{range .QueryResult[1]}}{{if and (ge .errorLogCount 2) (le .errorLogCount 100)}}* {{.request_uri}} error log count: {{.errorLogCount}}{{end}}{{end}}
* /apple-touch-icon-144x144.png error log count: 3* /feed error log count: 3
{{if .QueryLog[0][0].apple}}apple exist, value is : {{.QueryLog[0][0].apple}}{{else}}apple is not exist{{end}}
{{- xxx}} or {{xxx -}}
- at the beginning or end of {{ }} to remove leading or trailing whitespace, respectively.{{- range .QueryResult[1]}}{{- if and (ge .errorLogCount 2) (le .errorLogCount 100)}}* {{.request_uri}} error log count: {{.errorLogCount}}{{- end}}{{- end}}
* /apple-touch-icon-144x144.png error log count: 3* /feed error log count: 3
Function | Note: | Example | |
Escaping special characters | {{escape .variable}} | Escapes special characters such as " so that variables can be placed in JSON to maintain correct JSON formatting. | Variable value: The variable value of {{.ExecuteQuery[0]}} is status:>=400 | select count(*) as "error log count".Function example: {{escape .ExecuteQuery[0]}}Returned results: status:>=400 | select count(*) as \\"error log count\\" |
| {{escape_markdown .variable}} | Escapes special characters such as * and # so that variables can be placed in Markdown to maintain correct Markdown formatting.Applicable to the WeCom bot notification channel. | |
| {{escape_markdown_html .variable}} | Escapes special characters such as * and # so that variables can be placed in Markdown to maintain correct Markdown formatting.Applicable to the DingTalk and Feishu bot notification channels. | |
Extracting strings | {{substr .variable start}} | Extracts a string from the specified start position with an optional length. Both the start position and length are calculated in bytes. Generally, each letter or digit occupies 1 byte. | Variable value: The variable value of {{.QueryLog[0][0].fileName}} is /root/testLog/nginx.log.Function example: {{substr .QueryLog[0][0].fileName 6 7 }}Returned results: testLog |
| {{substr .variable start length}} | | |
| {{extract .variable startStringRegex}} | Extracts a string based on the specified start string and optional end string. Both the start and end strings are specified using regular expressions. | Variable value: The variable value of {{.QueryLog[0][0].fileName}} is /root/testLog/nginx.log.Function example: {{extract .QueryLog[0][0].fileName "/root/" "/nginx"}}Returned results: testLog |
| {{extract .variable startStringRegex endStringRegex}} | | |
| {{trim .variable}} | Removes leading and trailing whitespace characters from the original string. | Function example: {{trim " Hello, World! "}} Returned results: Hello, World! |
| {{trimPrefix prefix .variable}} | Removes the specified prefix from the original string. | Function example: {{trimPrefix "hello" "hello, world!"}}Returned results: , world! |
| {{trimSuffix suffix .variable}} | Removes the specified suffix from the original string. | Function example: {{trimSuffix "world!" "hello, world!"}} Returned results: hello, |
Case conversion | {{lower .variable}} | Converts all characters in the original string to lowercase. | Function example: {{lower "HELLO WORLD"}} Returned results: hello world |
| {{upper .variable}} | Converts all characters in the original string to uppercase. | Function example: {{upper "hello world"}}Returned results: HELLO WORLD |
| {{title .variable}} | Converts the original string to title case, capitalizing the first letter of each word and making the rest lowercase. | Function example: {{title "hello world"}}Returned results: Hello World |
String replacement | {{replace(oldstr,newstr,originstr)}} | Replaces a substring oldstr in the specified string originstr with another substring newstr. | Function example: {{replace "foo" "bar" "foo bar foo"}} Returned results: bar bar bar |
| {{regexReplaceAll(regex,originstr,newstr)}} | Replaces the substring that matches the regular expression regex in the specified string originstr with the specified string newstr. | Function example: {{regexReplaceAll "h" "hello world" "H"}} Returned results: Hello world |
String matching | {{containstr .variable searchstring}} | Check if the variable value contains the specified string. The result can be used in conditional judgment syntax. | Variable value: The variable value of {{.QueryLog[0][0].fileName}} is /root/testLog/nginx.log.Function example: {{if containstr .QueryLog[0][0].fileName "test"}}test log{{else}}non-test log{{end}}Returned results: test log |
| {{regexMatch(regex,string)}} | Determines whether the specified string matches the regular expression. If a match occurs, true is returned; otherwise, false is returned. | Function example: {{regexMatch "^hello" "hello world"}}Returned results: true |
Concatenating strings | {{concat .variable1 .variable2 ...}} | Concatenates the specified variables or strings together. | Function example: {{concat .Region .Alarm}}Returned results: Excessive Nginx error logs in Guangzhou |
Splitting strings | {{splitList delimiter string}} | Splits the string string into an array using the delimiter delimiter. | Function example: {{splitList "," "apple,banana,orange"}} Returned results: ["apple" "banana" "orange"] |
Sorting strings | {{sortAlpha stringList}} | Sorts the list of strings in alphabetical order. It does not sort in-place; instead, it returns a sorted copy of the list, adhering to the principle of list immutability. | Function example: {{sortAlpha (splitList "," "banana,apple,orange")}}Returned results: ["apple","banana","orange"] |
Counting length or number of elements | {{len .variable}} | Obtains the number of elements in arrays or maps, and the length of strings. Does not support retrieving the length of numeric values. | Variable value: The variable value of {{.QueryResult}} is[[{"number":19778,"text":"hello"}],[]]Function example:
Returned results:
|
Function | Note: | Example | |
Addition | {{add .variable1 .variable2 ...}} | Integer (int64) addition operation | Function example: {{ add 5 3 }}Returned results: 8 |
| {{addf .variable1 .variable2 ...}} | Floating-point number (float64) addition operation | |
Subtraction | {{sub .variable1 .variable2}} | Integer (int64) subtraction operation | Function example: {{ sub 10 3 }}Returned results: 7 |
| {{subf .variable1 .variable2}} | Floating-point number (float64) subtraction operation | |
Division | {{div .variable1 .variable2}} | Integer (int64) division operation | Function example: {{ div 10 2 }} Returned results: 5 |
| {{divf .variable1 .variable2}} | Floating-point number (float64) division operation | |
Modulo | {{mod .variable1 .variable2}} | Integer (int64) modulo operation | Function example: {{ mod 10 3 }}Returned results: 1 |
Multiplication | {{mul .variable1 .variable2}} | Integer (int64) multiplication operation | Function example: {{ mul 4 5 }} Returned results: 20 |
| {{mulf .variable1 .variable2}} | Floating-point number (float64) multiplication operation | |
Minimum value | {{min .variable1 .variable2 ...}} | Minimum value from integer (int64) | Function example: {{ min 3 7 }} Returned results: 3 |
| {{minf .variable1 .variable2 ...}} | Minimum value from floating-point number (float64) | |
Maximum Value | {{max .variable1 .variable2 ...}} | Maximum value from integer (int64) | Function example: {{ max 3 7 }}Returned results: 7 |
| {{maxf .variable1 .variable2 ...}} | Maximum value from floating-point number (float64) | |
Rounding | {{ceil .variable}} | Rounding up | Function example: {{ ceil 5.3 }}Returned results: 6 |
| {{floor .variable}} | Rounding down | |
Rounding | {{round .variable decimal}} | Rounds the value variable to the specified decimal place decimal. | Function example: {{ round 5.6748 2 }}Returned results: 5.67 |
Function | Note: | Example |
{{atoi .variable}} | Converts a string to an integer. | Function example:
Returned results:
|
{{float64 .variable}} | Converts the value to the float64 type. | |
{{int .variable}} | Converts the value to the int type matching the system width. | |
{{int64 .variable}} | Converts the value to the int64 type. | |
{{toString .variable}} | Converts the value to a string. | |
Function | Note: | Example | |
Converting a UNIX timestamp | {{fromUnixTime .variable}} | Converts UNIX timestamp (support millisecond and second timestamp) to a readable date and time. The time zone is optional, with the default set to Asia/Shanghai. | Variable value: The variable value of {{.QueryLog[0][0].time}} is 1653893435008.Function example:
Returned results:
|
| {{fromUnixTime .variable "timezone"}} | | |
Time formatting | {{date "2006-01-02 15:04:05" .variable}} | Converts the specified timestamp to a string in the specified format. The first parameter specifies the time format, based on 2006-01-02 15:04:05, which can be adjusted. | Function example:
Returned results:
Description: .NotifyTimeUnix is a millisecond timestamp, which is converted to a second timestamp by dividing by 1000 using div. |
| {{dateInZone "2006-01-02 15:04:05" .variable timezone}} | Supports specifying the timezone, similar to the date function | |
| {{duration .variable}} | Converts a duration in seconds to a human-readable format. | Function example: {{duration (mul .Duration 60)}}Returned results: 4h23m0sDescription: .Duration indicates the alarm duration in minutes, which is converted to seconds by multiplying by 60 using mul. |
Function | Note: | Example |
{{toPrettyJson .variable}} | Converts the specified parameter into a formatted JSON string for easy display. | Function example: {{toPrettyJson .TriggerResult}}Returned results:
|
Function | Note: | Example |
{{base64_encode .variable}} {{base64_decode .variable}} {{base64url_encode .variable}} {{base64url_decode .variable}} {{url_encode .variable}} {{url_decode .variable}} | Encodes or decodes the specified variable or string. For Base64URL, padding characters (=) are not removed or added during encoding and decoding. | Function example:
Returned results:
|
{{md5 .variable}} {{md5 .variable | base64_encode}} {{md5 .variable | base64url_encode}} {{sha1 .variable}} {{sha1 .variable | base64_encode}} {{sha1 .variable | base64url_encode}} {{sha256 .variable}} {{sha256 .variable | base64_encode}} {{sha256 .variable | base64url_encode}} {{sha512 .variable}} {{sha512 .variable | base64_encode}} {{sha512 .variable | base64url_encode}} | Encrypts the specified variable or string using a specific encryption algorithm. The default returned result is encoded as a hexadecimal string, which can be modified as needed to Base64 or Base64URL encoding. | Function example:
Returned results:
|
{{hmac_md5 .variable "Secretkey"}} {{hmac_md5 .variable "Secretkey" | base64_encode}} {{hmac_md5 .variable "Secretkey" | base64url_encode}} {{hmac_sha1 .variable "Secretkey"}} {{hmac_sha1 .variable "Secretkey" | base64_encode}} {{hmac_sha1 .variable "Secretkey" | base64url_encode}} {{hmac_sha256 .variable "Secretkey"}} {{hmac_sha256 .variable "Secretkey" | base64_encode}} {{hmac_sha256 .variable "Secretkey" | base64url_encode}} {{hmac_sha512 .variable "Secretkey"}} {{hmac_sha512 .variable "Secretkey" | base64_encode}} {{hmac_sha512 .variable "Secretkey" | base64url_encode}} | Encrypts the specified variable or string using a specific encryption algorithm. The default returned result is encoded as a hexadecimal string, which can be modified as needed to Base64 or Base64URL encoding. Secretkey is the key for the HMAC encryption algorithm and can be modified as needed. | Function example:
Returned results:
|
{{range $key,$value := .QueryLog[0][0].content}}{{if not (containstr $key "__TAG__")}}{{- $key}}:{{$value}}{{- end}}{{- end}}
.QueryLog[0][0] represents the most recent detailed log that matches the search conditions of the first execution statement in the alarm policy. Its value is as follows:{"content": {"__TAG__": {"a": "b12fgfe","c": "fgerhcdhgj"},"body_bytes_sent": "33704","http_referer": "-","http_user_agent": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36","remote_addr": "247.0.249.191","remote_user": "-","request_method": "GET","request_uri": "/products/hadoop)","status": "404","time_local": "01/Nov/2018:07:54:08"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-210B","source": "172.17.0.2","time": 1653908859008,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}
remote_addr:247.0.249.191time_local:01/Nov/2018:07:54:08http_user_agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36remote_user:-http_referer:-body_bytes_sent:33704request_method:GETrequest_uri:/products/hadoop)status:404
{{- range .QueryLog}}{{- range .}}{{.content}}{{- end}}{{- end}}
.QueryLog represents the detailed logs that match the search conditions of all execution statements in the alarm policy (up to a maximum of 10 logs). Its value is as follows:{"QueryLog": [[{"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "32847","http_referer": "-","http_user_agent": "Opera/9.80 (Windows NT 6.1; U; en-US) Presto/2.7.62 Version/11.01","remote_addr": "105.86.148.186","remote_user": "-","request_method": "GET","request_uri": "/apple-touch-icon-144x144.png","status": "404","time_local": "01/Nov/2018:00:55:14"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5CD","source": "172.17.0.2","time": 1653739000013,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}, {"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "33496","http_referer": "-","http_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36","remote_addr": "222.18.168.242","remote_user": "-","request_method": "GET","request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html","status": "404","time_local": "01/Nov/2018:00:54:37"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5C8","source": "172.17.0.2","time": 1653738975008,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}],[{"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "32847","http_referer": "-","http_user_agent": "Opera/9.80 (Windows NT 6.1; U; en-US) Presto/2.7.62 Version/11.01","remote_addr": "105.86.148.186","remote_user": "-","request_method": "GET","request_uri": "/apple-touch-icon-144x144.png","status": "404","time_local": "01/Nov/2018:00:55:14"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5CD","source": "172.17.0.2","time": 1653739000013,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}, {"content": {"__TAG__": {"pod": "nginxPod","cluster": "testCluster"},"body_bytes_sent": "33496","http_referer": "-","http_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36","remote_addr": "222.18.168.242","remote_user": "-","request_method": "GET","request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html","status": "404","time_local": "01/Nov/2018:00:54:37"},"fileName": "/root/testLog/nginx.log","pkg_id": "285A243662909DE3-5C8","source": "172.17.0.2","time": 1653738975008,"topicId": "a54de372-ffe0-49ae-a12e-c340bb2b03f2"}]]}
{"__TAG__":{"pod":"nginxPod","cluster":"testCluster"},"body_bytes_sent":"32847","http_referer":"-","http_user_agent":"Opera/9.80 (Windows NT 6.1; U; en-US) Presto/2.7.62 Version/11.01","remote_addr":"105.86.148.186","remote_user":"-","request_method":"GET","request_uri":"/apple-touch-icon-144x144.png","status":"404","time_local":"01/Nov/2018:00:55:14"},{"__TAG__":{"pod":"nginxPod","cluster":"testCluster"},"body_bytes_sent":"33496","http_referer":"-","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36","remote_addr":"222.18.168.242","remote_user":"-","request_method":"GET","request_uri":"/opt/node_apps/test-v5/app/themes/basic/public/static/404.html","status":"404","time_local":"01/Nov/2018:00:54:37"},{"__TAG__":{"pod":"nginxPod","cluster":"testCluster"},"body_bytes_sent":"32847","http_referer":"-","http_user_agent":"Opera/9.80 (Windows NT 6.1; U; en-US) Presto/2.7.62 Version/11.01","remote_addr":"105.86.148.186","remote_user":"-","request_method":"GET","request_uri":"/apple-touch-icon-144x144.png","status":"404","time_local":"01/Nov/2018:00:55:14"},{"__TAG__":{"pod":"nginxPod","cluster":"testCluster"},"body_bytes_sent":"33496","http_referer":"-","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36","remote_addr":"222.18.168.242","remote_user":"-","request_method":"GET","request_uri":"/opt/node_apps/test-v5/app/themes/basic/public/static/404.html","status":"404","time_local":"01/Nov/2018:00:54:37"}
status:>=400 | select count(*) as errorLogCount,request_uri group by request_uri order by count(*) desc
Trigger condition: $1.errorLogCount > 10{{range .QueryResult[0]}}{{- if gt .errorLogCount 10}}{{.request_uri}} error log count: {{.errorLogCount}}{{- end}}{{- end}}
.QueryResult[0] represents the execution result of the first execution statement in the alarm policy. Its value is as follows:[{"errorLogCount": 161,"request_uri": "/apple-touch-icon-144x144.png"}, {"errorLogCount": 86,"request_uri": "/opt/node_apps/test-v5/app/themes/basic/public/static/404.html"}, {"errorLogCount": 33,"request_uri": "/feed"}, {"errorLogCount": 26,"request_uri": "/wp-login.php"}, {"errorLogCount": 10,"request_uri": "/safari-pinned-tab.svg"}, {"errorLogCount": 7,"request_uri": "/mstile-144x144.png"}, {"errorLogCount": 4,"request_uri": "/atom.xml"}, {"errorLogCount": 3,"request_uri": "/content/plugins/prettify-gc-syntax-highlighter/launch.js?ver=3.5.2?ver=3.5.2"}]
/apple-touch-icon-144x144.png error log count: 161/opt/node_apps/elastic-v5/app/themes/basic/public/static/404.html error log count: 86/feed error log count: 33/wp-login.php error log count: 26

{{.QueryResult[0][0].host}} represents the host field in the first row of the execution result for the first execution statement."{{.QueryResult[0][0].host}}". Use single quotation marks for SQL statements, for example, '{{.QueryResult[0][0].host}}'.Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback