6.18. Logging#
Added in version 1.17.0: Nubus for Kubernetes 1.17.0 has structured logging deactivated by default.
This page is for operators and describes how to configure logging for Nubus for Kubernetes components.
6.18.1. Structured logging#
Structured logging outputs log messages in a standardized format with consistent fields. This format supports integration with log management systems, such as Elasticsearch or similar tools.
This change affects the following components:
UDM HTTP REST API
UMC Server
6.18.1.1. Log format#
Structured log lines use the following format in Listing 6.56. You find an example in Listing 6.57.
<timestamp> <severity:8> [<request ID>] <message>\t| <app data> <source code reference> [PID] [log facility] [traceback]
The fields have the following meaning:
timestampISO 8601 formatted timestamp with sub-second precision and timezone, for example
2023-10-27T08:22:57.275138+00:00.severityLog level, padded to 8 characters. For the available levels, see Logging levels.
request IDCorrelation ID for tracking requests across services. A dash (
-) indicates no request ID.messageThe log message text.
app dataKey-value pairs with application-specific data in
logfmtformat.source code referencePython module and line number that produced the log entry.
PIDProcess ID, optional.
log facilityLog facility, optional.
tracebackException traceback, optional.
2023-10-27T08:22:57.275138+00:00 INFO [31f863092a] modified group | dn="..." module=app.main pid=13825
2023-10-27T08:22:58.123454+00:00 DEBUG [ -] received request | method="POST" module=app.net pid=13825
6.18.1.2. Parsing log lines#
To parse structured log lines,
use the Python regular expression
in Listing 6.58.
Lines that don’t match this pattern are tracebacks or legacy univention.debug calls.
You can ignore them when parsing structured logs.
ADR0010_REGEX = (
r"^(?P<date>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,6}\+\d{2}:?\d{2}) +"
r"(?P<level>\w+?) +\[(?P<request_id>.*?)\] (?P<message>.+?)\t\| (?P<data>.*?)$"
)
6.18.1.3. Activate structured logging#
If you prefer the structured log format, you can enable structured logging using UCR variables.
To activate structured logging, add the configuration in Listing 6.59 to your
custom_values.yamlvalues file.After updating your configuration, apply the changes as described in Apply configuration.
global:
configUcr:
umc:
server:
debug:
structured-logging: "true"
module:
debug:
structured-logging: "true"
directory:
manager:
rest:
debug:
structured-logging: "true"
6.18.2. Logging levels#
You can configure the logging verbosity through UCR variables. The following logging levels are available:
Level |
Name |
Description |
|---|---|---|
0 |
ERROR |
Only error messages |
1 |
WARNING |
Warnings and errors |
2 |
INFO |
Informational messages. It’s the default setting. |
3 |
DEBUG |
Debug messages |
4 |
DEBUG (verbose) |
Verbose debug messages |
5 |
TRACE |
Trace-level logging for detailed debugging |
6.18.2.1. Configure logging levels#
To change the logging level for specific components,
add the configuration in Listing 6.60
to your custom_values.yaml values file.
After updating your configuration, apply the changes as described in Apply configuration.
global:
configUcr:
umc:
server:
debug:
level: 3
module:
debug:
level: 3
directory:
manager:
rest:
debug_level: 3
listener:
debug:
level: 3
See also
- Overview
for general information about configuring Nubus for Kubernetes.