11# Type Converter
22
3- The _ Type Converter Filter _ plugin allows to convert data type and append new key value pair .
3+ The _ Type Converter _ filter plugin converts data types and appends new key- value pairs .
44
55<img referrerpolicy =" no-referrer-when-downgrade " src =" https://static.scarf.sh/a.png?x-pxid=8984f540-d95a-462b-8a08-09f72f5fab63 " />
66
7- This plugin is useful in combination with plugins which expect incoming string value.
8- e.g. [ filter_grep] ( grep.md ) , [ filter_modify] ( modify.md )
7+ You can use this filter in combination with plugins which expect incoming string value. For example, [ Grep] ( grep.md ) and [ Modify] ( modify.md ) .
98
10- ## Configuration Parameters
9+ ## Configuration parameters
1110
1211The plugin supports the following configuration parameters. It needs four parameters.
1312
14- ` <config_parameter> <src_key_name> <dst_key_name> <dst_data_type> `
15-
16- _ dst_data_type_ allows ` int ` , ` uint ` , ` float ` and ` string ` .
17-
18- e.g. ` int_key id id_str string `
13+ ``` text
14+ <config_parameter> <src_key_name> <dst_key_name> <dst_data_type>`
15+ ```
1916
17+ ` dst_data_type ` allows ` int ` , ` uint ` , ` float ` , and ` string ` . For example, ` int_key id id_str string ` .
2018
2119| Key | Description |
2220| :--- | :--- |
23- | int_key | This parameter is for integer source.|
24- | uint_key | This parameter is for unsigned integer source.|
25- | float_key| This parameter is for float source.|
26- | str_key | This parameter is for string source.|
21+ | ` int_key ` | This parameter is for an integer source.|
22+ | ` uint_key ` | This parameter is for an unsigned integer source.|
23+ | ` float_key ` | This parameter is for a float source.|
24+ | ` str_key ` | This parameter is for a string source.|
2725
28- ## Getting Started
26+ ## Get started
2927
30- In order to start filtering records, you can run the filter from the command line or through the configuration file.
28+ To start filtering records, you can run the filter from the command line or through the configuration file.
3129
32- This is a sample in \_ mem record to filter.
30+ This is a sample ` in_mem ` record to filter.
3331
3432``` text
3533{"Mem.total"=>1016024, "Mem.used"=>716672, "Mem.free"=>299352, "Swap.total"=>2064380, "Swap.used"=>32656, "Swap.free"=>2031724}
3634```
3735
38- The plugin outputs uint values and filter_type_converter converts them into string type.
36+ The plugin outputs ` uint ` values and ` filter_type_converter ` converts them into string type.
3937
40- ### Convert uint to string
38+ ### Convert ` uint ` to string
4139
4240{% tabs %}
4341{% tab title="fluent-bit.conf" %}
42+
4443``` python
4544[INPUT ]
4645 Name mem
@@ -56,9 +55,11 @@ The plugin outputs uint values and filter_type_converter converts them into stri
5655 Name stdout
5756 Match *
5857```
58+
5959{% endtab %}
6060
6161{% tab title="fluent-bit.yaml" %}
62+
6263``` yaml
6364pipeline :
6465 inputs :
@@ -74,13 +75,14 @@ pipeline:
7475 - name : stdout
7576 match : ' *'
7677` ` `
78+
7779{% endtab %}
7880{% endtabs %}
7981
8082You can also run the filter from command line.
8183
82- ` ` ` text
83- $ fluent-bit -i mem -o stdout -F type_converter -p 'uint_key=Mem.total Mem.total_str string' -p 'uint_key=Mem.used Mem.used_str string' -p 'uint_key=Mem.free Mem.free_str string' -m '*'
84+ ` ` ` shell
85+ fluent-bit -i mem -o stdout -F type_converter -p 'uint_key=Mem.total Mem.total_str string' -p 'uint_key=Mem.used Mem.used_str string' -p 'uint_key=Mem.free Mem.free_str string' -m '*'
8486```
8587
8688The output will be
0 commit comments