Simple Log Service not only collects logs, but also monitors Knative Services for exceptions using its alerting feature. You can define custom alert rules, including check frequency and trigger conditions, and set up corresponding alert notification policies. If a Service exception occurs, notifications are promptly sent to operations and development teams through channels such as DingTalk, text messages, and emails. This ensures uninterrupted service operations.
Prerequisites
A Knative Service is deployed. For more information, see Quickly deploy a Knative service.
The Knative Service is integrated with log collection. For more information, see Enable Simple Log Service on Knative.
Step 1: Query and analyze logs
This section describes how to query and analyze logs in the Simple Log Service console. For more information, see Query and analyze logs.
Log on to the Simple Log Service console.
In the Projects section, click the project you want.
In the left-side navigation pane, click Log Storage. In the Logstores list, click the logstore you want.
Enter a statement into the search box below the Logstore name and click Search & Analyze.
For example, to monitor Services based on the number of errors that have occurred, enter the following SQL statement:
* | select 'ERROR' , count(1) as total group by 'ERROR'
This SQL statement lists all records that contain the error field, counts the number of the records, and then classifies the records by error.
Step 2: Configure an alert monitoring rule
Log on to the Simple Log Service console.
In the Projects section, click the project you want.
In the left-side navigation pane, click Log Storage. In the Logstores list, click the logstore you want.
On the query and analysis page, click the icon.
In the Alert Monitoring Rules section, set up the alert rules.
For guidance on configuring alert rules, refer to Create log alert monitoring rules.
Establish alert notification policies.
For instructions on setting alert notifications, see Quickly set log alerts.
Run the following command to reach the helloworld-go service:
An alert will be triggered.
curl -H "Host: helloworld-go.default.example.com" http://<Gateway IP> # Please use your actual data for Gateway IP and domain name.
Expected result:
Hello Knative!
References
Integrate Knative Service monitoring data with Prometheus Service and visualize it on a Grafana dashboard in real-time. For further details, see View Knative service monitoring dashboard.