This topic describes how to create a Kubernetes event center. After you create a Kubernetes event center, you can view event statistics, query event details, view pod lifecycle, configure alerts, and perform custom queries.
Background information
Kubernetes event centers record the status changes of Kubernetes clusters. A status change is recorded when you create, run, or delete a pod, or when a component exception occurs. Kubernetes event centers aggregate all events in Kubernetes clusters in real time and provides storage, search, analysis, visualization, and alert capabilities.
Billing
- If you do not extend the event retention period and the Kubernetes cluster generates 1,000 events each day, you can use the Kubernetes event center free of charge.
- If you extend the event retention period to 105 days and the Kubernetes cluster generates 1,000 events each day, you will be charged at a rate of USD 0.014 per day after 90 days. For more information, see Pay-as-you-go.
Step 1: Create an event center
Step 2: Deploy the eventer and node-problem-detector components
Before you can use the Kubernetes event center, you must deploy the eventer and node-problem-detector components in the Kubernetes cluster.
- Deploy the eventer and node-problem-detector components in an Alibaba Cloud Kubernetes cluster
In Alibaba Cloud Marketplace, the ack-node-problem-collector component of Kubernetes clusters includes the eventer and node-problem-detector subcomponents. For more information, see Scenario 3: Use node-problem-detector with kube-eventer to raise alerts upon node anomalies.
- Log on to the Alibaba Cloud Container Service for Kubernetes console.
- In the left-side navigation pane, choose .
- On the page that appears, click the Alibaba Cloud Apps tab. On this tab, click ack-node-problem-detector.
- On the page that appears, click the Parameters tab. On this tab, modify the parameter settings under the eventer field.
- enabled: Set the value of the enabled parameter under to true.
- topic: Optional. Set this parameter to your cluster name. The name can contain letters, underscores (_), and hyphens (-).
- project: Set this parameter to the name of the project that is associated with the event center.
- logstore: Set this parameter to k8s-event.
sinks: sls: enabled: true # If you want the monitoring results to be notified by sls, set enabled to true. topic: "my-cluster" project: "{sls-project-name}" # You can view the project information by logging in to the # SLS console. Please fill in the name of the project here. # eg: your project name is k8s-log-cc18a5f3443dhdss22654da, # then you can fill k8s-log-cc18a5f3443dhdss22654da to project label. logstore: "k8s-event" # You can view the project information by logging in to the # SLS console. Please fill the logstore address in here.
- Click Create to complete the deployment.
- Deploy the eventer and node-problem-detector components in a user-created Kubernetes cluster
- For more information about how to deploy the eventer component, see Collect Kubernetes events.
- For more information about how to deploy the node-problem-detector component, visit GitHub.
Step 3: Use the event center
After you create a Kubernetes event center and deploy the eventer and node-problem-detector components, you can use the Kubernetes event center. You can use the event center to view event statistics, query event details, view pod lifecycle, configure alerts, and perform custom queries.
In the left-side navigation pane of the K8s Event Center page, find the target event center and click to perform the following operations.
Operation | Description |
---|---|
View event statistics | Click Event Overview to view the statistics of important events. For example, you can view the number of error events (compared with yesterday or last week), statistics of warning events, trends of top 10 important events, and statistics of pod out of memory (OOM) events.
Note If an OOM event occurs, you cannot view the information about the relevant pod. You can view only the node, process name, and process ID of the event. However, you can query the pod restart event around the time when the pod OOM event occurred. Then, you can find the pod.
|
Query event details | Click Event Details. On the page that appears, set one or more search conditions, including level, type, target, host, namespace, and name. Then, you can view the statistics and details of events. |
View the lifecycle of a pod | Click Pod Lifecycle. On the page that appears, set the search conditions. The information of all events that occurred on the pod are displayed in a chart. You can filter warning events or error events of the pod by severity level. |
Configure an alert | Click Alert Configuration to configure an event alert. For more information, see Procedure. |
Perform custom queries | Click Custom Query to query events by using custom search conditions. For information about the query syntax, see Overview. All events in the event center are stored in the Logstore. You can use all features of the Logstore. For example, you can perform custom queries, process consumption events, and create custom reports or alerts.
To obtain the name of the project that is associated with the event center, use one of the following two methods:
|
Configure custom alerts | A Kubernetes event center supports system alerts. The Kubernetes event center also allows you to configure custom alerts. Click Custom Query. On the page that appears, enter a statement to query a Kubernetes event, and click Save as Alert. In the dialog box that appears, set the required parameters of the alert. For more information, see Alert Overview. The following example shows how to create an alert named FailedPreStopHook. Enter the query statement
Note If the alert name is prefixed with K8s, you can view the alert in the
Events section of the page that appears after you click
Alert Configuration. Otherwise, you can view the alert only in the Modify Alert dialog box.
|
The following procedure describes how to configure an alert:
- In the left-side navigation pane of the K8s Event Center page, find the target event center and click
.
- Click Alert Configuration. The Events page appears.
- Add a notification method.
- Enable an alert notification.
Delete an event center
Choose icon in the Actions column to delete the event center.
FAQ
- Why is data unavailable in a Kubernetes event center?
After you deploy a Kubernetes event center, new events are collected to the event center. You can click Custom Query to query the events. We recommend that you set the query time range to 1 Day. If no data is available in the Kubernetes event center, the possible causes are:
- After you deploy the Kubernetes event center, no events are generated in the associated Kubernetes cluster.
You can run the
kubectl get events --all-namespaces
command to check whether new events are generated in the cluster. - The specified parameter values are invalid when you deploy the eventer and node-problem-detector components.
- If the associated cluster is an Alibaba Cloud Kubernetes cluster, log on to the Alibaba Cloud Container Service for Kubernetes console. Choose Update to view the configurations of the ack-node-problem-detector component. For more information, see Step 2: Deploy the eventer and node-problem-detector components. . On the page that appears, select the associated cluster from the Cluster drop-down list, and click
- If the associated cluster is a user-created Kubernetes cluster, follow the instructions in Collect Kubernetes events to check the parameters.
- After you deploy the Kubernetes event center, no events are generated in the associated Kubernetes cluster.
- How do I view the logs of the pod that is associated with an event?
- If the associated cluster is an Alibaba Cloud Kubernetes cluster, log on to the Alibaba Cloud Container Service for Kubernetes console. Choose kube-system from the Namespace drop-down list. Enter the keyword eventer in the search box to search for the target pod. Click View Details to view the logs of the pod. . On the page that appears, select the associated cluster from the Cluster drop-down list, and select
- If the associated cluster is a user-created Kubernetes cluster, you can view the logs of the target pod whose name is prefixed with event-sls. In addition, the pod is in the kube-system namespace.