Logging agent for Kubernetes
The Kubernetes logging agent collects and forwards logs to your IBM Log Analysis instance. After you provision an IBM® Log Analysis instance, you must configure a logging agent for each log source that you want to monitor.
As of 28 March 2024 the IBM Log Analysis and IBM Cloud Activity Tracker services are deprecated and will no longer be supported as of 30 March 2025. Customers will need to migrate to IBM Cloud Logs, which replaces these two services, prior to 30 March 2025. For information about IBM Cloud Logs, see the IBM Cloud Logs documentation.
The logging agent for Kubernetes automatically collects STDOUT and STDERR logs.
The logging agent tails for new log data, and looks for new files that are added to the logging directories that the agent monitors.
Before you begin, understand the agent storage requirements.
Logging agent images
Logging agent images for Kubernetes clusters are public images that are available in IBM Cloud through the IBM Cloud Container Registry service.
-
The logging agent images are hosted in the IBM Cloud Container Registry global repository
icr.io/ext/logdna-agent
. -
IBM Cloud Container Registry provides a multi-tenant, highly available, scalable, and encrypted private image registry that is hosted and managed by IBM.
-
The IBM Cloud Container Registry includes Vulnerability Advisor features that scan for potential security issues and vulnerabilities. Vulnerability Advisor checks for vulnerable packages in specific Docker base images, and known vulnerabilities in app configuration settings. When vulnerabilities are found, information about the vulnerability is provided. You can use this information to resolve security issues so that containers are not deployed from vulnerable images.
To get details about the logging agent images, see Getting information about logging agent images.
Resource Limits for agents deployed on Kubernetes
The agent is deployed as a Kubernetes DaemonSet, creating one pod for each node selected. The agent collects logs of all the pods in the node. The resource requirements of the agent are in direct relation to the number of pods for each node and the amount of logs produced for each pod.
The agent requires at least 128 MB and no more than 512 MB of memory. It requires at least twenty millicpu (20m).
Different features can also increase resource utilization. When line exclusion, inclusion or redaction rules are specified, you can expect additional CPU consumption for each line and regex rule defined. When Kubernetes event logging is enabled (disabled by default), additional CPU usage will occur on the oldest agent pod.
Placing traffic shaping or CPU limits on the agent is not recommended to ensure data can be sent to the log ingestion service.
Image versions
The following table outlines the logging agent versions that are available to configure for a Kubernetes cluster:
Kubernetes cluster | logging agent V3 | logging agent V2 | logging agent V1 |
---|---|---|---|
Standard Kubernetes cluster |
|||
OpenShift Kubernetes cluster |
Not available |
The logging agent v2 is available only for Kubernetes 1.9+.
Choosing a version
When you configure the logging agent, you can choose any of the following options:
- You can use the default YAML file that is provided. Choose by region and by type of account. The default configuration pulls the image
icr.io/ext/logdna-agent:stable
. - You can use an existing YAML file and change the
image:tag
value in your existing YAML file to pull a specific image from the registry.
If you have a highly regulated environment, you can customize the YAML file. You can modify the YAML file so that it pulls from the IBM Cloud Container Registry global repository icr.io/ext/
the image that you specify, for example,
image: icr.io/ext/logdna-agent:X.Y.Z-<date>.[hash]
. Consider keeping a copy of the customized YAML file in a version control system.
Connecting a logging agent with a logging instance
The logging agent is responsible for collecting and forwarding system-level, and file-based logs to your IBM Log Analysis instance.
To connect your Kubernetes cluster to send logs to your IBM Log Analysis instance, you must install a logging-agent pod on each node of your cluster.
-
The logging agent reads log files from the pod where it is installed, and forwards the log data to your logging instance.
-
The logging agent collects STDOUT, STDERR, logs with the extension
*.log
, and extensionsless files that are stored in the/var/log
directory of your pod. By default, logs are collected from all namespaces, includingkube-system
, and automatically forwarded to the IBM Log Analysis service. -
To connect an agent to a standard Kubernetes cluster, see Connecting a logging agent for a standard Kubernetes cluster.
-
To connect an agent to an OpenShift Kubernetes cluster, see Connecting a logging agent for an OpenShift Kubernetes cluster.
Detaching a logging agent from a cluster
To stop your Kubernetes cluster from sending logs to your IBM Log Analysis instance, you must remove the logging agent from your cluster. Learn more.
Platform | How to install and configure |
---|---|
Standard Kubernetes cluster |
Detaching a logging agent from a standard Kubernetes cluster |
OpenShift Kubernetes cluster |
Detaching a logging agent from an Openshift Kubernetes cluster |
Running the agent as non-root
The default YAML files to configure a logging agent do not include running the agent as non-root.
To run the agent as non-root, see Preparing the version 3 yaml file to run the agent as non-root.
Configuration the agent
You can customize a logging agent by configuring the environment variables for Kubernetes agents.