Overview
Kubernetes Audit Log Monitoring provides deep visibility into all interactions with the Kubernetes API server. Every request made to the Kubernetes API is recorded, including requests from:- Control plane components (scheduler, controllers)
- Node components (kubelet, kube-proxy)
- Cluster services
- Users interacting through
kubectl - Applications calling the Kubernetes API
- Track all API server activity in the cluster
- Detect unauthorized access and privilege escalation
- Identify RBAC policy misconfigurations
- Monitor resource lifecycle events (create, update, delete)
- Investigate security incidents and suspicious activity
- Diagnose permission issues and API failures
Requirements
Enabling Kubernetes Audit Logs
For more information about setting up Kubernetes audit logs, see Kubernetes Auditing. For K8s Selfhosted, configure the K8s server with audit logging enabled. To enable audit logs in Kubernetes:- Audit logs are disabled by default in Kubernetes. To enable them in your API server configuration, specify an audit policy file path:
- Create the policy file at /etc/kubernetes/audit-policies/policy.yaml to specify the types of API requests you want to capture in your audit logs. Audit policy rules are evaluated in order. The API server follows the first matching rule it finds for each type of operation or resource. Example of an audit policy:
Installing the Atatus Agent Helm Chart
If the Atatus agent is not installed in your Kubernetes cluster, first install the agent by following the Kubernetes installation guide Install Atatus Agent using Helm Once the agent is installed, you can update the Helm chart to enable Kubernetes audit log monitoring. Update Helm Repository Add the Atatus Helm repository if it is not already configured:This upgrades the existing agent deployment and applies the configuration changes required for Kubernetes audit log collection.
Agent Configuration
The Atatus agent must be configured to:- Enable log collection
- Mount the Kubernetes audit log directory
- Read the audit log file
Enable Log Collection
Editvalues.yaml:
Mount Kubernetes Audit Logs
Kubernetes audit logs are written on the node filesystem by the API server. The Atatus agent must mount this directory to read and ship the logs. Add the audit log directory as a hostPath volume in values.yaml.
Verify the Log File Exists
Before deploying the agent, verify that the audit log file exists on the node:
Update the DaemonSet Template
Edittemplate/daemonset.yaml:
To enable file log collection, the files.yml configuration must be mounted inside the agent container.
Update the templates/daemonset.yaml file in the Helm chart to mount the configuration file.
Add the following volume mount inside the container volumeMounts section:
If the audit log file does not exist, ensure Kubernetes audit logging is enabled on the API server.
Configure Log Collection
Configure the agent to collect the audit log file. Editvalues.yaml:
K3s Full Example Setup
The following example shows a complete K3s setup without changing the generic Kubernetes configuration above.1. Create the K3s audit policy file
Create/var/lib/rancher/k3s/server/audit.yaml on the K3s server:
2. Update the K3s server config
Edit/etc/rancher/k3s/config.yaml:
3. K3s-specific values.yaml example
Because K3s writes audit logs to /var/lib/rancher/k3s/server/logs/audit.log, use that host path in the Helm values:
4. Update the DaemonSet template for files.yml
Add the following mount inside the container volumeMounts section in templates/daemonset.yaml:
files.yml configuration from values.yaml is mounted into the Atatus agent container.
5. Deploy and verify
Deploy the Agent
Deploy or upgrade the Helm chart:Example Security Events
Kubernetes audit logs capture important cluster activities such as:
Example audit event:
Viewing Audit Events
Audit events appear in: Security → Cloud SIEM → Kubernetes Audit Logs Each event includes:- User or service account
- Resource type and namespace
- API operation (create, update, delete)
- Source IP address
- Request status
- Timestamp
- Audit stage