From now to December 31, 2021, audit log and event data generated by EKS is free of charge. Select Auto-create Logset or select Auto-create Log Topic in an existing logset. For more information, see Free Tier.
Cluster auditing is a feature based on Kubernetes Auditing that can store and search for the records of JSON logs with configurable policies generated by kube-apiserver. It records the access events of kube-apiserver and the activities of each user, admin, or system add-on that has an impact on the cluster in sequence.
Cluster auditing provides a cluster monitoring dimension other than metrics. After it is enabled, Kubernetes can record every audit log of operations on the cluster. An audit log is a structured record in JSON format and includes metadata
, requestObject
, and responseObject
. Metadata (containing the request context, such as who initiated the request, where it was initiated, and the accessed URI) is required, while requestObject
and responseObject
are optional, depending on the audit level. You can learn about the following information from logs:
{
"kind":"Event",
"apiVersion":"audit.k8s.io/v1",
"level":"RequestResponse",
"auditID":0a4376d5-307a-4e16-a049-24e017******,
"stage":"ResponseComplete",
// What happened
"requestURI":"/apis/apps/v1/namespaces/default/deployments",
"verb":"create",
// Who initiated the request
"user":{
"username":"admin",
"uid":"admin",
"groups":[
"system:masters",
"system:authenticated"
]
},
// Where was it initiated
"sourceIPs":[
"10.0.6.68"
],
"userAgent":"kubectl/v1.16.3 (linux/amd64) kubernetes/ald64d8",
// What happened
"objectRef":{
"resource":"deployments",
"namespace":"default",
"name":"nginx-deployment",
"apiGroup":"apps",
"apiVersion":"v1"
},
// What's the result
"responseStatus":{
"metadata":{
},
"code":201
},
// Request and response details
"requestObject":Object{...},
"responseObject":Object{...},
// When did it start or end
"requestReceivedTimestamp":"2020-04-10T10:47:34.315746Z",
"stageTimestamp":"2020-04-10T10:47:34.328942Z",
// Reason for accepting or rejecting the request
"annotations":{
"authorization.k8s.io/decision":"allow",
"authorization.k8s.io/reason":""
}
}
Unlike general logs, Kubernetes audit logs have a level that is more like a kind of verbose configuration, which is used to indicate the degree of detail of the recorded information. There are four levels as listed below:
Parameter | Description |
---|---|
None | Nothing is logged. |
Metadata | The metadata (for example, user, time, resource, and operation) of the request is logged, excluding the message bodies of the request and response. |
Request | The metadata and request message body are logged, excluding the response message body. |
RequestResponse | All information is logged, including the metadata and the message bodies of the request and response. |
Logging can occur at different stages as listed below:
Parameter | Description |
---|---|
RequestReceived | The log is created when the request is received. |
ResponseStarted | The log is created after the message header of the response is sent. This parameter only applies to persistent connection requests, such as WATCH. |
ResponseComplete | The log is created after the response is completely sent. |
Panic | The request is not completed due to an internal server error. |
By default, EKS creates audit logs when receiving requests. For most operations, audit logs at the RequestResponse level are created, except for the following cases:
The following requests will not be logged:
system:kube-proxy
to monitor Endpoints, Services, or Services/Status.system:unsecured
for ConfigMaps in the kube-system
namespace.system:kube-controller-manager
, system:kube-scheduler
, or system:serviceaccount:endpoint-controller
for Endpoints in the kube-system
namespace.system:apiserver
for namespaces, namespaces/status, or namespaces/finalize resources./healthz*
, /version
, or /swagger*
.Note:To enable cluster auditing, you need to restart kube-apiserver. We recommend you not enable and disable it frequently.
Elastic Cluster
type as shown below:
Was this page helpful?