# 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="https://2771001740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUHgqKYgCiRKdOpWQdi52%2Fuploads%2Fgit-blob-20935e2e2c21a7c390b6821a683c38e3e0ad25a4%2Fimage.png?alt=media" 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="https://2771001740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUHgqKYgCiRKdOpWQdi52%2Fuploads%2Fgit-blob-46c0370e13d77e0b3b89546d4d318ffa8cbd6710%2Fimage.png?alt=media" alt="" width="563"><figcaption><p>auto-complete label values from traces</p></figcaption></figure>
