Skip to content

Commit 4d28be0

Browse files
authored
Merge pull request #29354 from bergerhoffer/OSDOCS-1532
OSDOCS-1532: Adding docs for filtering audit logs
2 parents e088215 + f51b054 commit 4d28be0

File tree

2 files changed

+70
-11
lines changed

2 files changed

+70
-11
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * security/audit-log-view.adoc
4+
5+
[id="security-audit-log-basic-filtering_{context}"]
6+
= Filtering audit logs
7+
8+
You can use `jq` or another JSON parsing tool to filter the API server audit logs.
9+
10+
[NOTE]
11+
====
12+
The amount of information logged to the API server audit logs is controlled by the audit log policy that is set.
13+
====
14+
15+
The following procedure provides examples of using `jq` to filter audit logs on control plane node `node-1.example.com`. See the link:https://stedolan.github.io/jq/manual/[jq Manual] for detailed information on using `jq`.
16+
17+
.Prerequisites
18+
19+
* You have access to the cluster as a user with the `cluster-admin` role.
20+
* You have installed `jq`.
21+
22+
.Procedure
23+
24+
* Filter OpenShift API server audit logs by user:
25+
+
26+
[source,terminal]
27+
----
28+
$ oc adm node-logs node-1.example.com \
29+
--path=openshift-apiserver/audit.log \
30+
| jq 'select(.user.username == "myusername")'
31+
----
32+
33+
* Filter OpenShift API server audit logs by user agent:
34+
+
35+
[source,terminal]
36+
----
37+
$ oc adm node-logs node-1.example.com \
38+
--path=openshift-apiserver/audit.log \
39+
| jq 'select(.userAgent == "cluster-version-operator/v0.0.0 (linux/amd64) kubernetes/$Format")'
40+
----
41+
42+
* Filter Kubernetes API server audit logs by a certain API version and only output the user agent:
43+
+
44+
[source,terminal]
45+
----
46+
$ oc adm node-logs node-1.example.com \
47+
--path=kube-apiserver/audit.log \
48+
| jq 'select(.requestURI | startswith("/apis/apiextensions.k8s.io/v1beta1")) | .userAgent'
49+
----
50+
51+
* Filter Kubernetes API server audit logs by excluding a verb:
52+
+
53+
[source,terminal]
54+
----
55+
$ oc adm node-logs node-1.example.com \
56+
--path=kube-apiserver/audit.log \
57+
| jq 'select(.verb != "get")'
58+
----

security/audit-log-view.adoc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
:context: audit-log-view
21
[id="audit-log-view"]
32
= Viewing audit logs
43
include::modules/common-attributes.adoc[]
4+
:context: audit-log-view
55

66
toc::[]
77

8+
Audit provides a security-relevant chronological set of records documenting the sequence of activities that have affected the system by individual users, administrators, or other components of the system.
89

9-
Audit provides a security-relevant chronological set of records documenting the
10-
sequence of activities that have affected the system by individual users,
11-
administrators, or other components of the system.
12-
10+
// About the API audit log
11+
include::modules/nodes-nodes-audit-log-basic.adoc[leveloffset=+1]
1312

14-
// The following include statements pull in the module files that comprise
15-
// the assembly. Include any combination of concept, procedure, or reference
16-
// modules required to cover the user story. You can also include other
17-
// assemblies.
13+
// Viewing the audit log
14+
include::modules/nodes-nodes-audit-log-basic-viewing.adoc[leveloffset=+1]
1815

16+
// Filtering audit logs
17+
include::modules/security-audit-log-filtering.adoc[leveloffset=+1]
1918

20-
include::modules/nodes-nodes-audit-log-basic.adoc[leveloffset=+1]
19+
[id="viewing-audit-logs-additional-resources"]
20+
== Additional resources
2121

22-
include::modules/nodes-nodes-audit-log-basic-viewing.adoc[leveloffset=+1]
22+
* link:https://github.com/kubernetes/apiserver/blob/master/pkg/apis/audit/v1/types.go#L72[API audit log event structure]
23+
* xref:../security/audit-log-policy-config.adoc#audit-log-policy-config[Configuring the audit log policy]

0 commit comments

Comments
 (0)