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.
| Attribute | Description |
|---|---|
k8s.namespace.name | The namespace in which the pod is running. |
k8s.deployment.name | The Deployment that owns the pod. |
k8s.statefulset.name | The StatefulSet that owns the pod, if applicable. |
k8s.daemonset.name | The DaemonSet that owns the pod, if applicable. |
k8s.replicaset.name | The ReplicaSet that owns the pod. |
k8s.cronjob.name | The CronJob that owns the pod, if applicable. |
k8s.job.name | The Job that owns the pod, if applicable. |
k8s.node.name | The name of the node where the pod is running. |
k8s.pod.name | The name of the pod. |
k8s.pod.ip | The IP address assigned to the pod. |
k8s.pod.uid | The unique identifier (UID) of the pod. |
k8s.container.name | The name of the container within the pod. |
type | Always set to log, indicating the record type. |
k8s.cluster.name | The name of the Kubernetes cluster. |
k8s.cluster.resourceUUID | The 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_attributesare 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
| Attribute | Description |
|---|---|
k8s.pod.hostname | The hostname of the pod. |
k8s.pod.start_time | The time when the pod started, in RFC 3339 format. |
Workload attributes
| Attribute | Description |
|---|---|
k8s.deployment.uid | The unique identifier (UID) of the Deployment. |
k8s.replicaset.uid | The unique identifier (UID) of the ReplicaSet. |
k8s.daemonset.uid | The unique identifier (UID) of the DaemonSet. |
k8s.statefulset.uid | The unique identifier (UID) of the StatefulSet. |
k8s.cronjob.uid | The unique identifier (UID) of the CronJob. |
k8s.job.uid | The unique identifier (UID) of the Job. |
Node and cluster attributes
| Attribute | Description |
|---|---|
k8s.node.uid | The unique identifier (UID) of the node. |
k8s.cluster.uid | The unique identifier (UID) of the Kubernetes cluster, derived from the UID of the kube-system namespace. |
Container-level attributes
| Attribute | Description |
|---|---|
container.id | The unique identifier (ID) of the container. |
container.image.name | The name of the container image (for example, nginx or redis). |
container.image.tag | The tag of the container image (for example, 1.21 or latest). |
container.image.repo_digests | The repository digest of the container image. |
Service attributes
| Attribute | Description |
|---|---|
service.namespace | The namespace of the service, derived from the pod metadata. |
service.name | The name of the service, derived from the pod metadata. |
service.version | The version of the service, derived from the container image tag. |
service.instance.id | The unique identifier (ID) of the service instance, derived from the pod UID. |
Note
Only attributes from the tables above are supported. Arbitrary or custom attribute names are not accepted.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
- Go to Infrastructure > Logs.
- Click any pod log entry to open its details.
- Additional attributes appear alongside the default attributes in the log record’s metadata.
- 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_attributesapplies 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.