Create an alert rule for a Metricstore
Simple Log Service supports PromQL, SQL, and PromQL+SQL syntax for querying and analyzing metrics. You can create alert rules to monitor key metrics and receive timely notifications. This topic provides common examples of creating alert rules for a Metricstore.
Create an alert rule by using PromQL
-
On the Metricstore query page, use a PromQL query to calculate the request growth rate, and then click Save as Alert in the upper-right corner.
rate(apiserver_request_total[1m])In the left-side Metricstore list, select sls-mall-k8s-metrics. Enter the PromQL query in the editor and click Run Query to view results.
-
On the Create Alert page, configure Rule Name, Check Frequency, Trigger Condition, and Destination, and then click OK. Quick start for creating an alert rule.
Create an alert rule by using SQL and PromQL
-
On the Metricstore page, choose to go to the query page of the corresponding Logstore.
-
On the Logstore query page, use SQL with PromQL functions to perform a nested query and preview results. Click the Save as Alert icon in the upper-right corner to create an alert rule. Configure an alert rule in Simple Log Service. Common alert rule examples:
-
The up metric indicates process liveness. Alert when a process is down:
* | select promql_query('up == 0') from metrics limit 1000 -
Alert when instance resident memory (tracked by
process_resident_memory_bytes) exceeds 8 GB:* | select promql_query('process_resident_memory_bytes/1024/1024/1024 > 8') from metrics limit 1000 -
Alert when CPU utilization exceeds 500%:
* | select promql_query('rate(process_cpu_seconds_total[1m]) > 5') from metrics limit 1000 -
Alert when goroutines in a Go process exceed 500:
* | select promql_query('sum by(instance) (go_goroutines) > 500') from metrics limit 1000 -
Alert when average garbage collection (GC) duration exceeds 0.1 seconds:
* | select promql_query('sum(rate(go_gc_duration_seconds_sum[1m])) by (instance) /sum(rate(go_gc_duration_seconds_count[1m])) by (instance) > 0.1') from metrics limit 1000
-
Example
This video shows how to create an alert rule for a Metricstore to monitor the CPU utilization of a host.