# Enrich logs, traces, events, and metrics with pod labels & annotations

groundcover allows you to add custom labels and annotations from Kubernetes pods and Docker containers to the metrics, traces, logs, and events generated by those pods or containers.

### Specifying what to collect

To apply custom labels and annotations collection, you need to update your groundcover deployment `values.yaml` file.

The `global.labelEnrichment` configuration allows you to control exactly which labels and annotations are attached to each signal type (metrics, logs, traces, events).

To collect specific pod labels per signal type:

```yaml
global:
  labelEnrichment:
    pods:
      labels:
        collectAll: false
        metrics: ["app", "team"]
        logs: ["app"]
        traces: ["app", "team", "version"]
        events: ["app", "team", "version", "tier"]
      annotations:
        collectAll: false
        metrics: ["prometheus.io/port"]
        logs: ["owner"]
        traces: ["owner"]
        events: ["owner", "oncall"]
```

To collect **all** pod labels and/or annotations for all signals:

```yaml
global:
  labelEnrichment:
    pods:
      labels:
        collectAll: true
      annotations:
        collectAll: true
```

{% hint style="warning" %}
When `collectAll` is `true`, per-signal lists (`metrics`, `logs`, `traces`, `events`) are ignored.
{% endhint %}

### Prefixes

We prefix the labels/annotations with the following (according to pod/docker):

* `k8s.pod.label`
* `k8s.pod.annotation`
* `docker.container.label`
* `docker.container.annotation`

<figure><img src="/files/IDi2BgINmAvb7MY1OM8N" alt=""><figcaption><p>pod labels in a span attributes</p></figcaption></figure>

### Searching labels and annotations

Once you've setup the configuration to the sensor, you will be able to view and search for specific labels and annotations like any other attribute.\
For example, to search for traces, logs, or events that have the label `app.kubernetes.io/part-of = groundcover` you can do the following search:\
`k8s.pod.label.app.kubernetes.io/part-of:groundcover` in the search bar.

<figure><img src="/files/2fzrFf4ZlscpchsnkouZ" alt="" width="563"><figcaption><p>auto-complete label values from traces</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/customization/customize-usage/custom-labels-and-annotations/enrich-logs-and-traces-with-pod-labels-and-annotations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
