# Labels

![](https://static.scarf.sh/a.png?x-pxid=1e9a2474-00c3-4d8d-b170-79996be7af79)

The *labels* processor lets you manipulate the labels of metrics.

Similar to filters, this processor presents an enriching/modifying mechanism to perform operations for labels manipulation. The most significant difference is that processors perform better than filters, and when chaining them there are no encoding or decoding performance penalties.

{% hint style="info" %}
Only [YAML configuration files](https://docs.fluentbit.io/manual/administration/configuring-fluent-bit/yaml) support processors.
{% endhint %}

## Configuration parameters

| Key      | Description                                                                                                                                                                                         |
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `delete` | Deletes a key from the labels of metrics. The key/value pair is required. If the specified key doesn't exist, the operation silently fails and has no effect.                                       |
| `hash`   | Replaces the key value with a hash generated by the SHA-256 algorithm from the specified label name. The generated binary value is set as a hex string.                                             |
| `insert` | Inserts a new key with a value into metrics. The key/value pair is required.                                                                                                                        |
| `update` | Updates an existing key with a value into metrics. The key/value pair is required. If the specified key doesn't exist, the operation silently fails and has no effect.                              |
| `upsert` | Upserts a specific key with a value, the `upsert` operation will try to update the value of the key. If the specified key doesn't exist, a new key will be created. The key/value pair is required. |

### Update example

The following example changes the value of the `name` key to `fluentbit`:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            update: name fluentbit

  outputs:
    - name : stdout
      match: '*'
```

{% endtab %}
{% endtabs %}

### Insert example

The following example appends the key `agent` with the value `fluentbit` as the label of metrics:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            insert: agent fluentbit

  outputs:
    - name : stdout
      match: '*'
```

{% endtab %}
{% endtabs %}

### Upsert example

The following example upserts the value of `name` and inserts `fluentbit`:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            upsert: name fluentbit

  outputs:
    - name : stdout
      match: '*'
```

{% endtab %}
{% endtabs %}

### Delete example

The following example deletes the `name` key from metrics:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            delete: name

  outputs:
    - name : stdout
      match: '*'
```

{% endtab %}
{% endtabs %}

### Hash example

The following example applies the SHA-256 algorithm for the value of the key `hostname`:

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: fluentbit_metrics

      processors:
        metrics:
          - name: labels
            hash: hostname

  outputs:
    - name : stdout
      match: '*'
```

{% endtab %}
{% endtabs %}


---

# 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.fluentbit.io/manual/data-pipeline/processors/labels.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.
