Skip to content

Commit dfaf16d

Browse files
committed
filter_logs_to_metrics: document field_value usage for counters
This documents a feature added with this PR: fluent/fluent-bit#10055 Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>
1 parent 644b24f commit dfaf16d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pipeline/filters/log_to_metrics.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Generate metrics from logs
88

99
## Log To Metrics
1010

11-
The _Log To Metrics Filter_ plugin allows you to generate log-derived metrics. It currently supports modes to count records, provide a gauge for field values or create a histogram. You can also match or exclude specific records based on regular expression patterns for values or nested values. This filter plugin does not actually act as a record filter and does not change or drop records. All records will pass this filter untouched and generated metrics will be emitted into a seperate metric pipeline.
11+
The _Log To Metrics Filter_ plugin allows you to generate log-derived metrics. It currently supports modes to count records or field values, provide a gauge for field values or create a histogram. You can also match or exclude specific records based on regular expression patterns for values or nested values. This filter plugin does not actually act as a record filter and does not change or drop records. All records will pass this filter untouched and generated metrics will be emitted into a seperate metric pipeline.
1212

1313
_Please note that this plugin is an experimental feature and is not recommended for production use. Configuration parameters and plugin functionality are subject to change without notice._
1414

@@ -25,7 +25,7 @@ The plugin supports the following configuration parameters:
2525
| bucket | Defines a bucket for `histogram` | Yes, for mode `histogram` | e.g. 0.75 |
2626
| add\_label | Add a custom label NAME and set the value to the value of KEY | | |
2727
| label\_field | Includes a record field as label dimension in the metric. | | Name of record key. Supports [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md) notation for nested fields. |
28-
| value\_field | Specify the record field that holds a numerical value | Yes, for modes \[`gauge` and `histogram`] | Name of record key. Supports [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md) notation for nested fields. |
28+
| value\_field | Specify the record field that holds a numerical value | Yes, for modes \[`gauge` and `histogram`, optional for `counter`] | Name of record key. Supports [Record Accessor](../../administration/configuring-fluent-bit/classic-mode/record-accessor.md) notation for nested fields. |
2929
| kubernetes\_mode | If enabled, it will automatically put pod\_id, pod\_name, namespace\_name, docker\_id and container\_name into the metric as labels. This option is intended to be used in combination with the [kubernetes](kubernetes.md) filter plugin, which fills those fields. | | |
3030
| Regex | Include records in which the content of KEY matches the regular expression. | | KEY REGEX |
3131
| Exclude | Exclude records in which the content of KEY matches the regular expression. | | KEY REGEX |
@@ -34,7 +34,7 @@ The plugin supports the following configuration parameters:
3434

3535
### Getting Started
3636

37-
The following example takes records from two dummy inputs and counts all messages passing through the `log_to_metrics` filter. It then generates metric records which are provided to the `prometheus_exporter`:
37+
The following example takes records from two dummy inputs and generates two different counter metrics: It counts all messages passing through the `log_to_metrics` filter and it counts the total time spend according to the duration field of each message. It then generates metric records which are provided to the `prometheus_exporter`:
3838

3939
#### Configuration - Counter
4040

@@ -61,6 +61,15 @@ The following example takes records from two dummy inputs and counts all message
6161
metric_name count_all_dummy_messages
6262
metric_description This metric counts dummy messages
6363

64+
[FILTER]
65+
name log_to_metrics
66+
match dummy.log*
67+
tag test_metric
68+
metric_mode counter
69+
metric_name total_duration
70+
metric_description This metric counts the total time spend
71+
value_field duration
72+
6473
[OUTPUT]
6574
name prometheus_exporter
6675
match *
@@ -76,7 +85,10 @@ You can then use e.g. curl command to retrieve the generated metric:
7685
7786
# HELP log_metric_counter_count_all_dummy_messages This metric counts dummy messages
7887
# TYPE log_metric_counter_count_all_dummy_messages counter
79-
log_metric_counter_count_all_dummy_messages 49
88+
log_metric_counter_count_all_dummy_messages 24
89+
# HELP log_metric_counter_total_duration This metric counts the total time spend
90+
# TYPE log_metric_counter_total_duration counter
91+
log_metric_counter_total_duration 960
8092
```
8193

8294
#### Configuration - Gauge

0 commit comments

Comments
 (0)