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.

Listing 6.56 Log format for structured logging#
<timestamp> <severity:8> [<request ID>] <message>\t| <app data> <source code reference> [PID] [log facility] [traceback]

The fields have the following meaning:

timestamp

ISO 8601 formatted timestamp with sub-second precision and timezone, for example 2023-10-27T08:22:57.275138+00:00.

severity

Log level, padded to 8 characters. For the available levels, see Logging levels.

request ID

Correlation ID for tracking requests across services. A dash (-) indicates no request ID.

message

The log message text.

app data

Key-value pairs with application-specific data in logfmt format.

source code reference

Python module and line number that produced the log entry.

PID

Process ID, optional.

log facility

Log facility, optional.

traceback

Exception traceback, optional.

Listing 6.57 Example for structured logging#
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.

Listing 6.58 Regular expression in Python for structured log lines#
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.

  1. To activate structured logging, add the configuration in Listing 6.59 to your custom_values.yaml values file.

  2. After updating your configuration, apply the changes as described in Apply configuration.

Listing 6.59 Activate structured logging for affected components#
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.

Listing 6.60 Configure logging levels for components#
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.