The OpsRamp Kubernetes 2.0 Agent automatically enriches every pod log record with core Kubernetes metadata, such as namespace, pod name, and deployment name. Starting with OpsRamp Kubernetes 2.0 Agent version 22.0.0, you can extend this further by adding additional Kubernetes attributes, giving you more precise filtering and correlation in the OpsRamp Logs UI.

Applies to: Pod logs only. Node logs (syslog records) are not affected.

Prerequisites

  • Log Management is enabled for your client.
  • Pod log collection is enabled. For details, see Configuring Pod Log Collection.
  • Available from Agent version 22.0.0 or later.

Default attributes

The following attributes are attached to every pod log record automatically. They cannot be removed or disabled.

AttributeDescription
k8s.namespace.nameThe namespace in which the pod is running.
k8s.deployment.nameThe Deployment that owns the pod.
k8s.statefulset.nameThe StatefulSet that owns the pod, if applicable.
k8s.daemonset.nameThe DaemonSet that owns the pod, if applicable.
k8s.replicaset.nameThe ReplicaSet that owns the pod.
k8s.cronjob.nameThe CronJob that owns the pod, if applicable.
k8s.job.nameThe Job that owns the pod, if applicable.
k8s.node.nameThe name of the node where the pod is running.
k8s.pod.nameThe name of the pod.
k8s.pod.ipThe IP address assigned to the pod.
k8s.pod.uidThe unique identifier (UID) of the pod.
k8s.container.nameThe name of the container within the pod.
typeAlways set to log, indicating the record type.
k8s.cluster.nameThe name of the Kubernetes cluster.
k8s.cluster.resourceUUIDThe OpsRamp resource UUID of the Kubernetes cluster.

Adding additional attributes

To attach extra metadata beyond the defaults, add a k8s_attributes list under pods in the opsramp-logs-user-config ConfigMap. Follow these steps:

Step 1: Edit the ConfigMap

kubectl edit configmap opsramp-logs-user-config -n <agent-installed-namespace>

Step 2: Add the k8s_attributes field

pods:
  enable: true
  k8s_attributes:
    - container.image.name
    - container.image.tag

Step 3: Save and apply

Save and close the editor. The agent detects the change automatically and restarts the OpenTelemetry collector with the updated configuration within a few minutes. No manual agent restart is required.

How it works

  • Attributes you list in k8s_attributes are appended to the default attribute list. They never replace or remove existing defaults.
  • If you specify an attribute that is already in the default list (for example, k8s.pod.name), it is automatically deduplicated and not added twice.
  • Duplicate entries within your own list are also removed automatically.
  • Only attributes from the supported list below can be configured. Arbitrary custom attribute names are not accepted.

Supported additional attributes

These are the metadata fields available via the OpenTelemetry Kubernetes Attributes Processor that are not already included by default.

Pod-level attributes

AttributeDescription
k8s.pod.hostnameThe hostname of the pod.
k8s.pod.start_timeThe time when the pod started, in RFC 3339 format.

Workload attributes

AttributeDescription
k8s.deployment.uidThe unique identifier (UID) of the Deployment.
k8s.replicaset.uidThe unique identifier (UID) of the ReplicaSet.
k8s.daemonset.uidThe unique identifier (UID) of the DaemonSet.
k8s.statefulset.uidThe unique identifier (UID) of the StatefulSet.
k8s.cronjob.uidThe unique identifier (UID) of the CronJob.
k8s.job.uidThe unique identifier (UID) of the Job.

Node and cluster attributes

AttributeDescription
k8s.node.uidThe unique identifier (UID) of the node.
k8s.cluster.uidThe unique identifier (UID) of the Kubernetes cluster, derived from the UID of the kube-system namespace.

Container-level attributes

AttributeDescription
container.idThe unique identifier (ID) of the container.
container.image.nameThe name of the container image (for example, nginx or redis).
container.image.tagThe tag of the container image (for example, 1.21 or latest).
container.image.repo_digestsThe repository digest of the container image.

Service attributes

AttributeDescription
service.namespaceThe namespace of the service, derived from the pod metadata.
service.nameThe name of the service, derived from the pod metadata.
service.versionThe version of the service, derived from the container image tag.
service.instance.idThe unique identifier (ID) of the service instance, derived from the pod UID.

Configuration examples

Example 1: Add container image details

Attach container image name and tag so you can filter logs by application version.

pods:
  enable: true
  k8s_attributes:
    - container.image.name
    - container.image.tag

Once applied, every pod log record includes the image name and tag as additional attributes, filterable in the OpsRamp console.

Example 2: Combine with other pod log settings

k8s_attributes works alongside other pod log settings, such as namespace filtering and log-level filtering.

pods:
  enable: true
  namespaces:
    include:
      - production
      - staging
    is_include_regex: false
  log_level: "Info"
  k8s_attributes:
    - container.image.name
    - container.image.tag

This configuration collects logs only from the production and staging namespaces, drops anything below Info severity, and attaches container image details to every remaining log record.

Viewing additional attributes in the portal

  1. Go to Infrastructure > Logs.
  2. Click any pod log entry to open its details.
  3. Additional attributes appear alongside the default attributes in the log record’s metadata.
  4. Use the + Filter option to filter logs by any configured attribute, including the ones you have added.

Important notes

  • Additional attributes are always appended and they never replace or remove default attributes.
  • k8s_attributes applies only to pod logs. Node logs (syslogs) are unaffected.
  • Only attributes from the supported list are accepted; arbitrary custom names are rejected.
  • Changes to the ConfigMap are picked up automatically and no manual agent restart required.