Kubernetes provides multiple metrics. You can collect the metrics from Kubernetes clusters to the Full-stack Observability application for visualization. Simple Log Service and Alibaba Cloud OpenAnolis have jointly developed the non-intrusive monitoring feature. You can use the feature to analyze network traffic flows and identify bottleneck issues for Kubernetes clusters in cloud-native scenarios.
Prerequisites
A Full-stack Observability instance is created. For more information, see Create an instance.
Limits
If you enable data plane monitoring, the host must use an x86_64 Linux kernel version 4.19 or later. For hosts that run CentOS 7.6 to 7.9, kernel version 3.1.0 is also supported. You can run the uname -r command to check the kernel version.
Step 1: Create a Logtail configuration
Log on to the Simple Log Service console.
In the Log Application section, click the Intelligent O&M tab. Then, click Full-stack Observability.
On the Simple Log Service Full-stack Observability page, click the instance you want.
-
In the left-side navigation pane, click Full-stack Monitoring.
If this is the first time you use Full-stack Monitoring for this instance, click Enable.
-
In the left-side navigation pane, click Data Collection. On the Data Import Configurations page, find Resource Monitoring in the Kubernetes Monitoring section.
If this is the first time you create a data access configuration for the target monitoring item, turn on the switch to open the configuration page. If a configuration already exists, click the
icon to open the configuration page. Create a machine group.
If a machine group is created, skip this step.
Create a machine group for a Container Service for Kubernetes (ACK) cluster. For more information, see Create an IP address-based machine group.
Create a machine group for a self-managed Kubernetes cluster. For more information, see Create a custom identifier-based machine group.
-
Download the custom resource definition (CRD) template tool.
Method
Description
Install from outside the cluster
Requires a
~/.kube/configfile on your local machine with permissions to run kubectl commands against the target cluster.Install from inside a container
Uses the permissions of the
alibaba-log-controllercomponent to create CRDs. Use this method if you do not have a~/.kube/configfile or if network issues prevent you from connecting to the cluster.Install from outside the cluster
-
Log on to your cluster and download the template tool.
-
China
curl https://logtail-release-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/kubernetes/crd-tool.tar.gz -o /tmp/crd-tool.tar.gz -
Regions outside China
curl https://logtail-release-ap-southeast-1.oss-ap-southeast-1.aliyuncs.com/kubernetes/crd-tool.tar.gz -o /tmp/crd-tool.tar.gz
-
-
Install the template tool. A successful installation generates the
sls-crd-toolexecutable in the current directory.tar -xvf /tmp/crd-tool.tar.gz -C /tmp &&chmod 755 /tmp/crd-tool/install.sh && sh -x /tmp/crd-tool/install.sh -
Run
./sls-crd-tool listto verify the installation. The installation is successful if the command returns any output.
Install from inside a container
-
Log on to the cluster and access the
alibaba-log-controllercontainer.kubectl get pods -n kube-system -o wide |grep alibaba-log-controller | awk -F ' ' '{print $1}' kubectl exec -it {pod} -n kube-system bash cd ~ -
Download the template tool.
-
If the cluster can access public networks, run one of the following commands:
-
China
curl https://logtail-release-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/kubernetes/crd-tool.tar.gz -o /tmp/crd-tool.tar.gz -
Regions outside China
curl https://logtail-release-ap-southeast-1.oss-ap-southeast-1.aliyuncs.com/kubernetes/crd-tool.tar.gz -o /tmp/crd-tool.tar.gz
-
-
If the cluster cannot access public networks, download the tool from outside the cluster and transfer it to the container by using a command such as
kubectl cp <source> <destination>or other file transfer methods supported by ACK.
-
-
Install the template tool. A successful installation generates the
sls-crd-toolexecutable in the current directory.tar -xvf /tmp/crd-tool.tar.gz -C /tmp &&chmod 755 /tmp/crd-tool/install.sh && sh -x /tmp/crd-tool/install.sh -
Run
./sls-crd-tool listto verify the installation. The installation is successful if the command returns any output.
-
-
Use the CRD template tool to generate a Logtail configuration.
-
Run the following command to view the definition of the template:
./sls-crd-tool get k8sMonitor -
Replace the REQUIRED parameter with the current instance ID and run the following command to preview the value of the parameter:
./sls-crd-tool apply -f template-k8sMonitor.yaml --create=false -
Check whether the project parameter specifies the project to which the current instance belongs. If yes, run the following command to deploy the template file:
./sls-crd-tool apply -f template-k8sMonitor.yaml -
Return to the Data Import Configurations page. If the installation is successful, the Configurations in Resource Monitoring is incremented by one. Otherwise, the count remains unchanged.
-
Resources for the monitoring component
The Kubernetes resources that are used to collect Kubernetes monitoring data are all created in the sls-monitoring namespace. The resources include one Deployment, one StatefulSet, one DaemonSet, and seven AliyunLogConfig CRDs.
Resource | Resource name | Description |
AliyunLogConfig |
{instance-id}-k8s-metas |
Collects Kubernetes configuration data, such as the name, namespace, label, image, and limit of Deployments, pods, Ingresses, and Services. By default, the collected data is stored in a Logstore named {instance}-metas. |
{instance-id}-k8s-metrics | Used to collect the metric data of Kubernetes clusters, including the CPU, memory, and network data of pods and containers. By default, the collected data is stored in a Metricstore named {instance}-k8s-metrics. | |
{instance-id}-k8s-metrics-kubelet | Used to collect the metric data of Kubernetes kubelet. By default, the collected data is stored in a Metricstore named {instance}-k8s-metrics. | |
{instance-id}-node-metas |
Collects the configuration data of Kubernetes nodes, such as CPU models and memory sizes. By default, the collected data is stored in a Logstore named {instance}-metas. |
|
{instance-id}-node-metrics | Used to collect the metric data of Kubernetes nodes, including CPU utilization and memory usage. By default, the collected data is stored in a Metricstore named {instance}-node-metrics. |
What to do next
After you collect Kubernetes monitoring data to Full-stack Observability, Full-stack Observability automatically creates dedicated dashboards for the monitoring data. You can use the dashboards to analyze the monitoring data. For more information, see View dashboards.