Skip to content

Commit ec2542a

Browse files
cosmo0920Patcnorris-cs
authored
processor_labels: Add a documentation for processor_labels (fluent#1371)
* processor_labels: Add a documentation for processor_labels Signed-off-by: Hiroshi Hatake <[email protected]> * processor_labels: Use SHA-256 instead of SHA-1 This is because using hash algorithm is actually SHA-256. Signed-off-by: Hiroshi Hatake <[email protected]> * Update labels.md Signed-off-by: Hiroshi Hatake <[email protected]> Co-authored-by: Pat <[email protected]> * processor_labels: Clarify an effect of absence of the target key when insert and delete operations Signed-off-by: Hiroshi Hatake <[email protected]> * Update pipeline/processors/labels.md Co-authored-by: Craig Norris <[email protected]> Signed-off-by: Hiroshi Hatake <[email protected]> * Update pipeline/processors/labels.md Co-authored-by: Craig Norris <[email protected]> Signed-off-by: Hiroshi Hatake <[email protected]> * Update pipeline/processors/labels.md Co-authored-by: Craig Norris <[email protected]> Signed-off-by: Hiroshi Hatake <[email protected]> * Update pipeline/processors/labels.md Co-authored-by: Craig Norris <[email protected]> Signed-off-by: Hiroshi Hatake <[email protected]> * Update pipeline/processors/labels.md Co-authored-by: Craig Norris <[email protected]> Signed-off-by: Hiroshi Hatake <[email protected]> --------- Signed-off-by: Hiroshi Hatake <[email protected]> Co-authored-by: Pat <[email protected]> Co-authored-by: Craig Norris <[email protected]>
1 parent ac4e7c1 commit ec2542a

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
* [Logfmt](pipeline/parsers/logfmt.md)
131131
* [Decoders](pipeline/parsers/decoders.md)
132132
* [Processors](pipeline/processors/README.md)
133+
* [Labels](pipeline/processors/labels.md)
133134
* [Content Modifier](pipeline/processors/content-modifier.md)
134135
* [Metrics Selector](pipeline/processors/metrics-selector.md)
135136
* [SQL](pipeline/processors/sql.md)

installation/sources/build-and-install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,4 @@ The following table describes the processors available on this version:
220220
| option | description | default |
221221
| :--- | :--- | :--- |
222222
| [FLB\_PROCESSOR\_METRICS\_SELECTOR](../../pipeline/processors/metrics-selector.md) | Enable metrics selector processor | On |
223+
| [FLB\_PROCESSOR\_LABELS](../../pipeline/processors/labels.md) | Enable metrics label manipulation processor | On |

pipeline/processors/labels.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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

Comments
 (0)