Back to Security Guide

Audit Logging & Monitoring

Detecting and Responding to Security Threats in Real-Time

Audit Logging & Monitoring Overview

Comprehensive logging and monitoring are essential for detecting and responding to security incidents. API audit logs track all cluster operations, while tools like Falco provide runtime security monitoring. Together, they create a complete visibility layer for your cluster.

💡 Key Insight: Logging without monitoring is useless. You must actively monitor logs for suspicious activity and alert on anomalies.

Kubernetes Audit Logging

Audit Log Levels

Sample Audit Policy

apiVersion: audit.k8s.io/v1 kind: Policy rules: # Log all requests at Metadata level - level: Metadata omitStages: - RequestReceived # Log pod exec commands at RequestResponse - level: RequestResponse resources: - group: "" resources: ["pods/exec"] # Log secret access - level: RequestResponse resources: - group: "" resources: ["secrets"]

Enable Audit Logging on API Server

--audit-log-path=/var/log/kubernetes/audit.log --audit-log-maxage=30 --audit-log-maxsize=100 --audit-policy-file=/etc/kubernetes/audit-policy.yaml

Runtime Security with Falco

Falco Overview

Falco is a runtime security tool that detects suspicious process, network, and file activity:

Install Falco

helm repo add falcosecurity https://falcosecurity.github.io/charts helm install falco falcosecurity/falco \ --namespace falco --create-namespace \ --set falco.grpc.enabled=true

Common Falco Rules

✓ Best Practice: Combine Falco with SIEM (Splunk, ELK) for centralized threat detection and response.

Alerting & Response

Set Up Alerting

Incident Response Playbook

1. Alert triggered (Falco/audit log) 2. Investigation (check logs, processes, network) 3. Containment (isolate pod, preserve evidence) 4. Analysis (understand attack) 5. Recovery (remediate, restore) 6. Post-incident (update rules, improve detection)

Example Alert Rules

Monitoring Best Practices