Use Kubernetes events for troubleshooting in Azure Kubernetes Service (AKS)

This article shows you how to use Kubernetes events to monitor and troubleshoot issues in your Azure Kubernetes Service (AKS) clusters.

What are Kubernetes events?

Events are one of the most prominent sources for monitoring and troubleshooting issues in Kubernetes. They capture and record information about the lifecycle of various Kubernetes objects, such as pods, nodes, services, and deployments. By monitoring events, you can gain visibility into your cluster's activities, identify issues, and troubleshoot problems effectively.

Kubernetes events don't persist throughout your cluster lifecycle, as there's no retention mechanism. Events are only available for one hour after the event is generated. To store events for a longer time period, enable Container insights.

Kubernetes event objects

The following table lists some key Kubernetes event objects:

Field name Description
type The type is based on the severity of the event:
Warning events signal potentially problematic situations, such as a pod repeatedly failing or a node running out of resources. They require attention, but might not result in immediate failure.
Normal events represent routine operations, such as a pod being scheduled or a deployment scaling up. They usually indicate healthy cluster behavior.
reason The reason why the event was generated. For example, FailedScheduling or CrashLoopBackoff.
message A human-readable message that describes the event.
namespace The namespace of the Kubernetes object that the event is associated with.
firstSeen Timestamp when the event was first observed.
lastSeen Timestamp of when the event was last observed.
reportingController The name of the controller that reported the event. For example, kubernetes.io/kubelet.
object The name of the Kubernetes object that the event is associated with.

For more information, see the official Kubernetes documentation.

View Kubernetes events

  • List all events in your cluster using the kubectl get events command.

    kubectl get events
    
  • Look at a specific pod's events by first finding the name of the pod and then using the kubectl describe pod command.

    kubectl get pods
    
    kubectl describe pod <pod-name>
    

Best practices for troubleshooting with events

Filtering events for relevance

You might have various namespaces and services running in your AKS cluster. Filtering events based on object type, namespace, or reason can help narrow down the results to the most relevant information.

For example, you can use the following command to filter events within a specific namespace:

kubectl get events --namespace <namespace-name>

Automating event notifications

To ensure timely response to critical events in your AKS cluster, set up automated notifications. Azure offers integration with monitoring and alerting services like Azure Monitor. You can configure alerts to trigger based on specific event patterns. This way, you're immediately informed about crucial issues that require attention.

Regularly reviewing events

Make a habit of regularly reviewing events in your AKS cluster. This proactive approach can help you identify trends, catch potential problems early, and prevent escalations. By staying on top of events, you can maintain the stability and performance of your applications.

Next steps

Now that you understand Kubernetes events, you can continue your monitoring and observability journey by enabling Container insights.