// Module included in the following assemblies:
//
// * microshift_configuring/microshift-audit-logs-config.adoc

:_mod-docs-content-type: PROCEDURE
[id="microshift-configuring-audit-log-values_{context}"]
= Configuring audit log values

[role="_abstract"]
To manage disk space, you can customize the audit log retention settings in the {microshift-short} configuration file. Adjusting values such as file age and size ensures that the system retains critical event data without exhausting local storage.

.Procedure

. Make a copy of the provided `config.yaml.default` file in the `/etc/microshift/` directory, renaming it `config.yaml`. Keep the new {microshift-short} `config.yaml` you create in the `/etc/microshift/` directory. The new `config.yaml` is read whenever the {microshift-short} service starts. After you create it, the `config.yaml` file takes precedence over built-in settings.

. Replace the default values in the `auditLog` section of the YAML with your desired valid values.
+
.Example default `auditLog` configuration
[source,yaml]
----
apiServer:
# ....
  auditLog:
    maxFileAge: 7
    maxFileSize: 200
    maxFiles: 1
    profile: Default
# ....
----
+
where:

`apiServer.auditLog.maxFileAge`:: Specifies the maximum time in days that log files are kept. Files older than this limit are deleted. In this example, after a log file is more than 7 days old, it is deleted. The files are deleted regardless of whether or not the live log has reached the maximum file size specified in the `maxFileSize` field. File age is determined by the timestamp written in the name of the rotated log file, for example, `audit-2024-05-16T17-03-59.994.log`. When the value is `0`, the limit is disabled.
`apiServer.auditLog.maxFileSize`:: The maximum audit log file size in megabytes. In this example, the file is rotated as soon as the live log reaches the 200 MB limit. When the value is set to `0`, the limit is disabled.
`apiServer.auditLog.maxFiles`:: The maximum number of rotated audit log files retained. After the limit is reached, the log files are deleted in order from oldest to newest. In this example, the value `1` results in only 1 file of size `maxFileSize` being retained in addition to the current active log. When the value is set to `0`, the limit is disabled.
`apiServer.auditLog.profile`:: Logs only metadata for read and write requests; does not log request bodies except for OAuth access token requests. If you do not specify this field, the `Default` profile is used.

. Optional: To specify a new directory for logs, you can stop {microshift-short}, and then move the `/var/log/kube-apiserver` directory to your desired location:

.. Stop {microshift-short} by running the following command:
+
[source,terminal]
----
$ sudo systemctl stop microshift
----
.. Move the `/var/log/kube-apiserver` directory to your desired location by running the following command:
+
[source,terminal]
[subs="+quotes"]
----
$ sudo mv /var/log/kube-apiserver __<~/kube-apiserver>__
----
+
Replace `_<~/kube-apiserver>_` with the path to the directory that you want to use.

.. If you specified a new directory for logs, create a symlink to your custom directory at `/var/log/kube-apiserver` by running the following command:
+
[source,terminal]
[subs="+quotes"]
----
$ sudo ln -s __<~/kube-apiserver>__ /var/log/kube-apiserver
----
+
Replace `_<~/kube-apiserver>_` with the path to the directory that you want to use. This enables the collection of logs in sos reports.

. If you are configuring audit log policies on a running instance, restart {microshift-short} by entering the following command:
+
[source,terminal]
----
$ sudo systemctl restart microshift
----
