Skip to content

Commit fae1ec9

Browse files
authored
out_loki: add label_map_path property (#895)
Signed-off-by: Takahiro Yamashita <[email protected]> Signed-off-by: Takahiro Yamashita <[email protected]>
1 parent c591698 commit fae1ec9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

pipeline/outputs/loki.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Be aware there is a separate Golang output plugin provided by [Grafana](https://
1919
| tenant\_id | Tenant ID used by default to push logs to Loki. If omitted or empty it assumes Loki is running in single-tenant mode and no X-Scope-OrgID header is sent. | |
2020
| labels | Stream labels for API request. It can be multiple comma separated of strings specifying `key=value` pairs. In addition to fixed parameters, it also allows to add custom record keys \(similar to `label_keys` property\). More details in the Labels section. | job=fluentbit |
2121
| label\_keys | Optional list of record keys that will be placed as stream labels. This configuration property is for records key only. More details in the Labels section. | |
22+
| label\_map\_path | Specify the label map file path. The file defines how to extract labels from each record. More details in the Labels section. | |
2223
| remove\_keys | Optional list of keys to remove. | |
2324
| drop\_single\_key | If set to true and after extracting labels only a single key remains, the log line sent to Loki will be the value of that key in line\_format. | off |
2425
| line\_format | Format to use when flattening the record to a log line. Valid values are `json` or `key_value`. If set to `json`, the log line sent to Loki will be the Fluent Bit record dumped as JSON. If set to `key_value`, the log line will be each item in the record concatenated together \(separated by a single space\) in the format. | json |
@@ -95,6 +96,48 @@ The following configuration examples generate the same Stream Labels:
9596
label_keys $sub['stream']
9697
```
9798

99+
the above configuration accomplish the same than this one:
100+
101+
```text
102+
[OUTPUT]
103+
name loki
104+
match *
105+
labels job=fluentbit, $sub['stream']
106+
```
107+
108+
both will generate the following Streams label:
109+
110+
```text
111+
job="fluentbit", stream="stdout"
112+
```
113+
114+
### Using the `label_map_path` property
115+
116+
The configuration property `label_map_path` is to read a JSON file that defines how to extract labels from each record.
117+
118+
The file should contain a JSON object. Each keys define how to get label value from a nested record. Each values are used as label names.
119+
120+
The following configuration examples generate the same Stream Labels:
121+
122+
map.json:
123+
```json
124+
{
125+
"sub": {
126+
"stream": "stream"
127+
}
128+
}
129+
```
130+
131+
The following configuration examples generate the same Stream Labels:
132+
133+
```text
134+
[OUTPUT]
135+
name loki
136+
match *
137+
label_map_path /path/to/map.json
138+
```
139+
140+
98141
the above configuration accomplish the same than this one:
99142

100143
```text

0 commit comments

Comments
 (0)