All Products
Search
Document Center

Container Service for Kubernetes:Collect log data of Knative components

Last Updated:Sep 20, 2023

You can collect the log of Knative components and analyze the operation of the Knative components and troubleshoot issues based on the collected log. This topic describes how to collect the Docker stdout log of Knative components by using Simple Log Service.

Prerequisites

Knative components and metrics

Background information

The following metrics of Knative components are collected:

  • Number of ready pods where the components are deployed.

  • CPU utilization of the pods where the components are deployed.

  • Memory utilization of the pods where the components are deployed.

Knative components include:

  • knative-serving

    • activator

    • autoscaler

    • autoscaler-hpa

    • controller

    • webhook

  • knative-eventing

    • eventing-controller

    • eventing-webhook

Procedure

  1. Log on to the ACK console.

  2. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  3. On the Clusters page, click the name of the cluster that you want to manage and click Cluster Information in the left-side navigation pane.

  4. Click the Cluster Resources tab and click the hyperlink to the right of Log Service Project.

  5. In the lower-left part of the Project Overview page, click Import Data.

  6. In the Import Data dialog box, click Integrate Now on the Docker Standard Output - Container card. Click Continue in the message that appears and complete the configuration.

    The following content describes how to configure the parameters on the Configure Data Source wizard page. For more information, see Configure log collection.

    The following sample code provides an example on how to configure the data source to collect the stdout log of the controller in the knative-serving namespace. On the Specify Data Source wizard page, switch to the Editor and add the following code block.

    {
        "inputs": [
            {
                "detail": {
                    "IncludeEnv": {
              "SYSTEM_NAMESPACE":"knative-serving" # Specify the namespace. 
            },
                    "IncludeLabel": {
              "io.kubernetes.container.name": "controller" # Specify the component name. 
                    },
                    "ExcludeLabel": {}
                },
                "type": "service_docker_stdout"
            }
        ]
    }
    数据采集
  7. After you complete the configuration, click Log Query to view the collected log.

    image.png