Open source · Python
KubeForenSys
Capture the forensic state of an Azure Kubernetes Service cluster into Azure Log Analytics: pod logs, events, RBAC, service accounts and more. Then investigate it with KQL.
# Clone and install
git clone git@github.com:invictus-ir/KubeForenSys.git
pip install -r requirements.txt
# Point it at the cluster (.env works too)
export CLUSTER_NAME="your-aks-cluster-name"
python3 kubeforensys.py --since_seconds 172800
✓ eight custom tables in Log AnalyticsWhat it does
A cluster in, KQL tables out
Reads the cluster through your kubeconfig and writes each data type to its own table in Azure Log Analytics.
How it works
From cluster to KQL in four steps
Defaults: the last 24 hours, a workspace named KubeForenSys-LAW, region westeurope. All can be changed.
- 01
Authenticate
Reads your kubeconfig (for AKS, from az aks get-credentials) and signs in to Azure with DefaultAzureCredential.
- 02
Provision
Creates the workspace, a data collection endpoint and one collection rule per data type.
- 03
Collect
Pulls pod logs, events, RBAC, service accounts and more from every namespace except kube-system, azure-arc and gatekeeper-system.
- 04
Query with KQL
Each data type lands in its own custom table. Data is kept for 30 days by default.
What it collects
Eight tables, one per data type
Each table can be queried with KQL in the Log Analytics workspace.
| Data | What | Table |
|---|---|---|
| Pod logs | Container logs from pods across namespaces | kubelogs_CL |
| Events | Kubernetes cluster events | kubeevents_CL |
| Command history | Shell history extracted from containers | commandhistory_CL |
| Service accounts | Service account configuration | serviceaccounts_CL |
| Suspicious pods | Pods flagged against the tool’s detection criteria | suspiciouspods_CL |
| RBAC | Roles and role bindings | rbacbindings_CL |
| CronJobs | CronJob container information | cronjobs_CL |
| Network policies | Network policy configuration | networkpolicies_CL |
Before you run it
Permissions, scope and clean-up
Built for AKS
The Azure ingestion path and the managedClusters/read permission are specific to Azure Kubernetes Service. Other managed Kubernetes services are not covered.
What it creates
A Log Analytics workspace, a data collection endpoint, one collection rule per data type and eight custom tables.
Clean-up
Not automated. Delete the created objects in the configured resource group in the Azure portal.
What it skips
The kube-system, azure-arc and gatekeeper-system namespaces are not collected.
Where it’s used
Where it fits
Investigating a compromised Kubernetes cluster.
OpenChecking a cluster for signs of compromise, as of a date.
Releases
No tagged releases yet
The repository has no published releases. Install from the main branch, and check the commit history for recent changes.
More tools
The rest of the toolkit
KubeForenSys
Captured the cluster and need help reading it?
A responder can query the tables with you.

