|
| 1 | +# Labels |
| 2 | + |
| 3 | +The **labels** processor lets you manipulate the labels of metrics. |
| 4 | + |
| 5 | +Similar to filters, this processor presents a enriching/modifying mechanism to |
| 6 | +perform operations for labels manipulation. The most significant difference is |
| 7 | +that processors perform better than filters, and when chaining them there are no |
| 8 | +encoding or decoding performance penalties. |
| 9 | + |
| 10 | +{% hint style="info" %} |
| 11 | +**Note:** Both processors and this specific component can be enabled only by using |
| 12 | +the YAML configuration format. Classic mode configuration format doesn't support |
| 13 | +processors. |
| 14 | +{% endhint %} |
| 15 | + |
| 16 | +## Configuration Parameters |
| 17 | + |
| 18 | +| Key | Description | |
| 19 | +| :----- | :---------- | |
| 20 | +| update | Update 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. | |
| 21 | +| insert | Insert a new key with a value into metrics. The key/value pair is required. | |
| 22 | +| upsert | Upsert a specific key with a value, the `upsert` operation will try to update the value of the key. If the key does not exist, the key will be created. The key-value pair is required. | |
| 23 | +| delete | Delete 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. | |
| 24 | +| hash | Replace 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. | |
| 25 | + |
| 26 | +#### Update example |
| 27 | + |
| 28 | +Change the value of the `name` to `fluentbit`: |
| 29 | + |
| 30 | +```yaml |
| 31 | +pipeline: |
| 32 | + inputs: |
| 33 | + - name: fluentbit_metrics |
| 34 | + processors: |
| 35 | + metrics: |
| 36 | + - name: labels |
| 37 | + update: name fluentbit |
| 38 | + outputs: |
| 39 | + - name : stdout |
| 40 | + match: '*' |
| 41 | +``` |
| 42 | +
|
| 43 | +#### Insert example |
| 44 | +
|
| 45 | +The following example appends the key `agent` with the value `fluentbit` as the label |
| 46 | +of metrics: |
| 47 | + |
| 48 | +```yaml |
| 49 | +pipeline: |
| 50 | + inputs: |
| 51 | + - name: fluentbit_metrics |
| 52 | + processors: |
| 53 | + metrics: |
| 54 | + - name: labels |
| 55 | + insert: agent fluentbit |
| 56 | + outputs: |
| 57 | + - name : stdout |
| 58 | + match: '*' |
| 59 | +``` |
| 60 | + |
| 61 | +#### Upsert example |
| 62 | + |
| 63 | +Upsert the value of `name` and insert `fluentbit`: |
| 64 | + |
| 65 | +```yaml |
| 66 | +pipeline: |
| 67 | + inputs: |
| 68 | + - name: fluentbit_metrics |
| 69 | + processors: |
| 70 | + metrics: |
| 71 | + - name: labels |
| 72 | + upsert: name fluentbit |
| 73 | + outputs: |
| 74 | + - name : stdout |
| 75 | + match: '*' |
| 76 | +``` |
| 77 | + |
| 78 | +#### Delete example |
| 79 | + |
| 80 | +Delete containing `name` key from metrics: |
| 81 | + |
| 82 | +```yaml |
| 83 | +pipeline: |
| 84 | + inputs: |
| 85 | + - name: fluentbit_metrics |
| 86 | + processors: |
| 87 | + metrics: |
| 88 | + - name: labels |
| 89 | + delete: name |
| 90 | + outputs: |
| 91 | + - name : stdout |
| 92 | + match: '*' |
| 93 | +``` |
| 94 | + |
| 95 | +#### Hash example |
| 96 | + |
| 97 | +Apply the SHA-1 algorithm for the value of the key `hostname`: |
| 98 | + |
| 99 | +```yaml |
| 100 | +pipeline: |
| 101 | + inputs: |
| 102 | + - name: fluentbit_metrics |
| 103 | + processors: |
| 104 | + metrics: |
| 105 | + - name: labels |
| 106 | + hash: hostname |
| 107 | + outputs: |
| 108 | + - name : stdout |
| 109 | + match: '*' |
| 110 | +``` |
0 commit comments