All Products
Search
Document Center

Container Service for Kubernetes:Configure alerting for Knative Services

最終更新日:Nov 19, 2024

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

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.

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project you want.

    image

  3. In the left-side navigation pane, click Log Storage. In the Logstores list, click the logstore you want.

    image

  4. 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.

    image.png

Step 2: Configure an alert monitoring rule

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project you want.

    image

  3. In the left-side navigation pane, click Log Storage. In the Logstores list, click the logstore you want.

    image

  4. On the query and analysis page, click the 告警图标 icon.

    image

  5. In the Alert Monitoring Rules section, set up the alert rules.

    For guidance on configuring alert rules, refer to Create log alert monitoring rules.

  6. Establish alert notification policies.

    For instructions on setting alert notifications, see Quickly set log alerts.

  7. 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.