Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 589 of 8028. Security and ObservabilityFree lesson

Monitoring Audit Logs for Threat Detection

Analyze aggregated audit logs using SIEM tools to detect suspicious API activity, unauthorized access attempts, and abnormal administrative behavior in real-time.

In this lesson, you will learn how to transform raw Kubernetes audit logs into actionable security intelligence using a Security Information and Event Management (SIEM) tool.

From Raw Logs to Threat Detection

Kubernetes audit logs capture the "who, what, where, and when" of every API request. While storing these logs is necessary for compliance, they are essentially "dead data" until you ingest them into a SIEM (like Splunk, ELK, or Datadog). Once aggregated, you can move from passive storage to active threat detection by correlating events that would otherwise go unnoticed.

Analyzing Suspicious Activity

To detect threats, you need to define behavioral baselines. In your SIEM, you should create alerts for patterns that deviate from normal administrative activity. For example, consider an unauthorized access attempt: a user successfully authenticates but immediately attempts to list secrets across multiple namespaces.

You can query your aggregated logs for these anomalies using structured syntax:

-- SIEM query to detect potential reconnaissance
SELECT user.username, verb, objectRef.resource 
FROM k8s_audit_logs 
WHERE verb = 'list' 
  AND objectRef.resource = 'secrets' 
  AND responseStatus.code = 200
  AND user.username != 'system:serviceaccount:monitoring:prometheus'

Identifying Abnormal Behavior

Real-time monitoring allows you to catch "low and slow" attacks. By tracking administrative behavior, you can trigger alerts for:

  • Privilege Escalation: An unexpected user or service account creating a ClusterRoleBinding.
  • Unauthorized Access: Multiple 403 Forbidden responses for a specific identity, indicating credential brute-forcing or lateral movement attempts.
  • Persistent Threats: Unexpected execution of exec commands into pods, especially in production namespaces where developers shouldn't have manual access.

By configuring your SIEM to parse these logs in real-time, you turn the audit stream into a security radar. When an alert triggers, your incident response team receives context-rich data, allowing them to isolate a compromised node or revoke a malicious token before an attacker exfiltrates sensitive cluster data.

Key Takeaway: Aggregating audit logs into a SIEM allows you to move beyond basic compliance by enabling real-time detection of behavioral anomalies and unauthorized API exploitation.