Dynamic Log Level

Overview

With predictable, easy-to-use APIs, you can dynamically manage container log levels at runtime without requiring a pod restart.

Data Flow

The CWC component exposes a REST API at /loglevels, and each pod has its own log-level ConfigMap. When a request targets a specific container, the handler parses the payload and updates the pod’s ConfigMap, which updates the mounted .minlevel.yaml file. The f5-log library watches this file and automatically applies the new log level to the container.

Before You Begin

  • Ensure the CWC is installed and running. Refer to Licensing APIs

  • Obtain the certificates. Refer to CWC

  • Refer to API Documentation for information on the JSON and relevant parameters.

Log Level REST API

This table lists the supported actions.

API Command Action
GET - List all Log Level resources in a namespace
- Get Log Level resource by name
PUT - Replace Log Level resource by name
PATCH - Update log levels of containers by name
DELETE - Reset Log Level resource by name

Sample Commands

GET Requests

List all Log Level resources in a namespace

The below command performs HTTPS GET to /v1alpha1/namespaces/{namespace}/loglevels to retrieve the current log-level settings for containers in the specified namespace, authenticated via mutual TLS (client certificate, key, and CA).

Syntax:

curl -X GET https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/{namespace}/loglevels 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key

Sample to list all log level resources in the f5-utils namespace.

curl -X GET https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/f5-utils/loglevels 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key

Get Log Level resource by name

The below command performs HTTPS GET to /v1alpha1/namespaces/{namespace}/loglevels/{name} to retrieve the log-level configuration for the containers of the specified log-level resource in the given namespace, using mutual TLS (client certificate, key, and CA).

Syntax:

curl -X GET https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/{namespace}/loglevels/{name} 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key

Sample to retrieve f5-tmm log level resource belonging to the f5-utils namespace.

curl -X GET https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/f5-utils/loglevels/f5-tmm 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key

PUT command

Replace Log Level resource by name

The below command performs HTTPS PUT to /v1alpha1/namespaces/{namespace}/loglevels/{name} to update log-level containers by replacing all the log-level resource configuration, using mutual TLS (client certificate, key, and CA). The JSON payload defines a LogLevel resource where spec.containers maps container names to desired levels (DEBUG, INFO, WARN, ERROR, FATAL).

curl -X PUT https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/{namespace}/loglevels/{name} 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key 
    -d '{"apiVersion": "v1alpha1", "kind": "LogLevel", "metadata": {"name": "<name>"},"spec": {"containers": {"<container_name>": "<log_level>"}}}'

Sample to replace the f5-tmm log level resource in the f5-utils namespace, replacing the existing containers configuration with a log level of DEBUG for f5-tmm-routing container.

curl -X PUT https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/f5-utils/loglevels/f5-tmm 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key 
    -d '{"apiVersion":  "v1alpha1", "kind":  "LogLevel", "metadata":  {"name":  "f5-tmm"},"spec": {"containers": {"f5-tmm-routing": "DEBUG"}}}'

PATCH command

Update log levels of containers by name

The below command performs HTTPS PATCH to /v1alpha1/namespaces/{namespace}/loglevels/{name} to update log-level containers by replacing all the log-level resource configuration, using mutual TLS (client certificate, key, and CA). The JSON payload defines a LogLevel resource where spec.containers maps container names to desired levels (DEBUG, INFO, WARN, ERROR, FATAL).

curl -X PATCH https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/{namespace}/loglevels/{name} 
    --cert client_certificate 
    --cacert ca_certificate 
    --key client_key 
    -d '{"spec": {"containers": {"container_name": "log_level"}}}'

Sample to update the log level configuration of the f5-tmm-routing container belonging to the f5-tmm log level resource.

curl -X PATCH https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/f5-utils/loglevels/f5-tmm 
    --cert client_certificate  
    --cacert ca_certificate 
    --key client_key 
    -d '{"spec": {"containers": {"f5-tmm-routing": "ERROR"}}}'

DELETE command

Reset Log Level resource by name

The below command performs HTTPS DELETE to /v1alpha1/namespaces/{namespace}/loglevels/{name} to reset the log levels of the containers within the specified log level resource to their default values.

curl -X DELETE https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/{namespace}/loglevels/{name}

Sample to reset log levels of the containers of f5-tmm log level resource.

curl -X DELETE https://f5-spk-cwc.f5-utils:30881/v1alpha1/namespaces/f5-utils/loglevels/f5-tmm