# Type converter

{% hint style="info" %}
**Supported event types:** `logs`
{% endhint %}

![](https://static.scarf.sh/a.png?x-pxid=8984f540-d95a-462b-8a08-09f72f5fab63)

The *Type converter* filter plugin converts data types and appends new key-value pairs.

You can use this filter in combination with plugins which expect incoming string value. For example, [Grep](/manual/data-pipeline/filters/grep.md) and [Modify](/manual/data-pipeline/filters/modify.md).

## Configuration parameters

The plugin supports the following configuration parameters. It needs four parameters.

```
<config_parameter> <src_key_name> <dst_key_name> <dst_data_type>`
```

`dst_data_type` allows `int`, `uint`, `float`, and `string`. For example, `int_key id id_str string`.

| Key         | Description                                       |
| ----------- | ------------------------------------------------- |
| `float_key` | This parameter is for a float source.             |
| `int_key`   | This parameter is for an integer source.          |
| `str_key`   | This parameter is for a string source.            |
| `uint_key`  | This parameter is for an unsigned integer source. |

## Get started

To start filtering records, you can run the filter from the command line or through the configuration file.

This is a sample `in_mem` record to filter.

```
{"Mem.total"=>1016024, "Mem.used"=>716672, "Mem.free"=>299352, "Swap.total"=>2064380, "Swap.used"=>32656, "Swap.free"=>2031724}
```

The plugin outputs `uint` values and `filter_type_converter` converts them into string type.

### Convert `uint` to string

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: mem

  filters:
    - name: type_converter
      match: '*'
      uint_key:
        - Mem.total Mem.total_str string
        - Mem.used  Mem.used_str  string
        - Mem.free  Mem.free_str  string

  outputs:
    - name: stdout
      match: '*'
```

{% endtab %}

{% tab title="fluent-bit.conf" %}

```
[INPUT]
  Name mem

[FILTER]
  Name               type_converter
  Match              *
  Uint_Key Mem.total Mem.total_str string
  Uint_Key Mem.used  Mem.used_str  string
  Uint_Key Mem.free  Mem.free_str  string

[OUTPUT]
  Name  stdout
  Match *
```

{% endtab %}
{% endtabs %}

You can also run the filter from command line.

```shell
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 '*'
```

The output will be

```
[0] mem.0: [1639915154.160159749, {"Mem.total"=>8146052, "Mem.used"=>4513564, "Mem.free"=>3632488, "Swap.total"=>1918356, "Swap.used"=>0, "Swap.free"=>1918356, "Mem.total_str"=>"8146052", "Mem.used_str"=>"4513564", "Mem.free_str"=>"3632488"}]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fluentbit.io/manual/data-pipeline/filters/type-converter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
