5.3. Configuring audit log values
You can configure audit log settings by using the MicroShift service configuration file.
Procedure
-
Make a copy of the provided
config.yaml.defaultfile in the/etc/microshift/directory, renaming itconfig.yaml. Keep the new MicroShiftconfig.yamlyou create in the/etc/microshift/directory. The newconfig.yamlis read whenever the MicroShift service starts. After you create it, theconfig.yamlfile takes precedence over built-in settings. Replace the default values in the
auditLogsection of the YAML with your desired valid values.Example default
auditLogconfigurationapiServer: # .... auditLog: maxFileAge: 71 maxFileSize: 2002 maxFiles: 13 profile: Default4 # ....- 1
- 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
maxFileSizefield. 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 is0, the limit is disabled. - 2
- 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. - 3
- 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
1results in only 1 file of sizemaxFileSizebeing retained in addition to the current active log. When the value is set to0, the limit is disabled. - 4
- 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
Defaultprofile is used.
Optional: To specify a new directory for logs, you can stop MicroShift, and then move the
/var/log/kube-apiserverdirectory to your desired location:Stop MicroShift by running the following command:
$ sudo systemctl stop microshiftMove the
/var/log/kube-apiserverdirectory to your desired location by running the following command:$ sudo mv /var/log/kube-apiserver <~/kube-apiserver>1 - 1
- 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-apiserverby running the following command:$ sudo ln -s <~/kube-apiserver> /var/log/kube-apiserver1 - 1
- 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 by entering the following command:
$ sudo systemctl restart microsohift