You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pipeline/outputs/loki.md
+75-24
Original file line number
Diff line number
Diff line change
@@ -10,28 +10,29 @@ Be aware there is a separate Golang output plugin provided by [Grafana](https://
10
10
11
11
## Configuration Parameters
12
12
13
-
| Key | Description | Default |
14
-
| :--- | :--- | :--- |
15
-
| host | Loki hostname or IP address. Do not include the subpath, i.e. `loki/api/v1/push`, but just the base hostname/URL. | 127.0.0.1 |
16
-
| uri | Specify a custom HTTP URI. It must start with forward slash.| /loki/api/v1/push |
17
-
| port | Loki TCP port | 3100 |
18
-
| tls | Use TLS authentication | off |
19
-
| http\_user | Set HTTP basic authentication user name ||
20
-
| http\_passwd | Set HTTP basic authentication password ||
21
-
| bearer\_token | Set bearer token authentication token value. ||
22
-
| header | Add additional arbitrary HTTP header key/value pair. Multiple headers can be set. ||
23
-
| 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. ||
24
-
| 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=fluent-bit |
25
-
| 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. ||
26
-
| 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. ||
27
-
| structured\_metadata | Optional comma-separated list of `key=value` strings specifying structured metadata for the log line. Like the `labels` parameter, values can reference record keys using record accessors. See [Structured metadata](#structured-metadata) for more information. ||
28
-
| remove\_keys | Optional list of keys to remove. ||
29
-
| 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. If set to `raw` and the log line is a string, the log line will be sent unquoted. | off |
30
-
| 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 |
31
-
| auto\_kubernetes\_labels | If set to true, it will add all Kubernetes labels to the Stream labels | off |
32
-
| tenant\_id\_key | Specify the name of the key from the original record that contains the Tenant ID. The value of the key is set as `X-Scope-OrgID` of HTTP header. It is useful to set Tenant ID dynamically. ||
33
-
| compress | Set payload compression mechanism. The only available option is gzip. Default = "", which means no compression. ||
34
-
| workers | The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. |`0`|
| host | Loki hostname or IP address. Do not include the subpath, i.e. `loki/api/v1/push`, but just the base hostname/URL. | 127.0.0.1 |
16
+
| uri | Specify a custom HTTP URI. It must start with forward slash. | /loki/api/v1/push |
17
+
| port | Loki TCP port | 3100 |
18
+
| tls | Use TLS authentication | off |
19
+
| http\_user | Set HTTP basic authentication user name ||
20
+
| http\_passwd | Set HTTP basic authentication password ||
21
+
| bearer\_token | Set bearer token authentication token value. ||
22
+
| header | Add additional arbitrary HTTP header key/value pair. Multiple headers can be set. ||
23
+
| 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. ||
24
+
| 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=fluent-bit |
25
+
| 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. ||
26
+
| 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. ||
27
+
| structured\_metadata | Optional comma-separated list of `key=value` strings specifying structured metadata for the log line. Like the `labels` parameter, values can reference record keys using record accessors. See [Structured metadata](#structured-metadata) for more information. ||
28
+
| structured\_metadata\_map\_keys | Optional comma-separated list of record key strings specifying record values of type map, used to dynamically populate structured metadata for the log line. Values can only reference record keys using record accessors, which should reference map values. Each entry from the referenced map will be used to add an entry to the structured metadata. See [Structured metadata](#structured-metadata) for more information. ||
29
+
| remove\_keys | Optional list of keys to remove. ||
30
+
| 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. If set to `raw` and the log line is a string, the log line will be sent unquoted. | off |
31
+
| 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 |
32
+
| auto\_kubernetes\_labels | If set to true, it will add all Kubernetes labels to the Stream labels | off |
33
+
| tenant\_id\_key | Specify the name of the key from the original record that contains the Tenant ID. The value of the key is set as `X-Scope-OrgID` of HTTP header. It is useful to set Tenant ID dynamically. ||
34
+
| compress | Set payload compression mechanism. The only available option is gzip. Default = "", which means no compression. ||
35
+
| workers | The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. |`0`|
35
36
36
37
## Labels
37
38
@@ -229,7 +230,7 @@ You can get the same behavior this flag provides in Loki with `drop_single_key`
lets you attach custom fields to individual log lines without embedding the
@@ -254,12 +255,62 @@ The following configuration:
254
255
structured_metadata pod=$kubernetes['pod_name']
255
256
```
256
257
257
-
258
258
Other common uses for structured metadata include trace and span IDs, process and thread IDs, and log levels.
259
259
260
260
Structured metadata is officially supported starting with Loki 3.0, and shouldn't be used
261
261
with Loki deployments prior to Loki 3.0.
262
262
263
+
#### Structured Metadata Maps
264
+
In addition to the `structured_metadata` configuration parameter, a `structured_metadata_map_keys` is available, which can be used to dynamically populate structured metadata from map values in the log record. `structured_metadata_map_keys` can be set with a list of record accessors, where each one should reference map values in the log record. Record accessors which do not match a map value will simply be skipped.
265
+
266
+
The following configuration is similar to the above, except now all entries in the log record map value `$kubernetes` will be used as structured metadata entries.
267
+
268
+
{% tabs %}
269
+
{% tab title="fluent-bit.conf" %}
270
+
```text
271
+
[OUTPUT]
272
+
name loki
273
+
match *
274
+
labels cluster=my-k8s-cluster, region=us-east-1
275
+
structured_metadata_map_keys $kubernetes
276
+
```
277
+
{% endtab %}
278
+
279
+
{% tab title="fluent-bit.yaml" %}
280
+
```yaml
281
+
outputs:
282
+
- name: loki
283
+
match: *
284
+
labels: cluster=my-k8s-cluster, region=us-east-1
285
+
structured_metadata_map_keys: $kubernetes
286
+
```
287
+
{% endtab %}
288
+
{% endtabs %}
289
+
290
+
Assuming the value `$kubernetes` is a map containing two entries `namespace_name` and `pod_name`, the above configuration is equivalent to:
This plugin inherit core Fluent Bit features to customize the network behavior and optionally enable TLS in the communication channel. For more details about the specific options available refer to the following articles:
0 commit comments