Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_kafka: Fix in kafka json parsing #7492

Merged
merged 5 commits into from
Jul 20, 2023

Conversation

tarruda
Copy link

@tarruda tarruda commented May 29, 2023

This fixes json parsing for in_kafka, also add data_format configuration option, for explicit parsing control.

Fixes #7481

@tarruda tarruda temporarily deployed to pr May 29, 2023 15:32 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 15:32 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 15:32 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 15:58 — with GitHub Actions Inactive
plugins/in_kafka/in_kafka.c Outdated Show resolved Hide resolved
plugins/in_kafka/in_kafka.c Outdated Show resolved Hide resolved
@tarruda tarruda temporarily deployed to pr May 29, 2023 18:57 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 18:57 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 18:57 — with GitHub Actions Inactive
@tarruda tarruda force-pushed the fix-in-kafka-json-parsing branch from 814aba8 to d2f345a Compare May 29, 2023 18:57
@tarruda tarruda temporarily deployed to pr May 29, 2023 18:58 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 18:58 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 18:58 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr May 29, 2023 19:17 — with GitHub Actions Inactive
Copy link
Collaborator

@leonardo-albertovich leonardo-albertovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this new setting to the documentation, especially if it changes the default behavior considering that before this plugin tried to decode json encoded data always (which is not the case anymore).

plugins/in_kafka/in_kafka.c Outdated Show resolved Hide resolved
plugins/in_kafka/in_kafka.c Outdated Show resolved Hide resolved
@tarruda tarruda temporarily deployed to pr June 20, 2023 12:08 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr June 20, 2023 12:08 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr June 20, 2023 12:08 — with GitHub Actions Inactive
Signed-off-by: Thiago Padilha <[email protected]>
This option allows automatic parsing of kafka messages payload with the
specified format. Right now only "json" is supported.

Signed-off-by: Thiago Padilha <[email protected]>
@edsiper
Copy link
Member

edsiper commented Jul 13, 2023

All good with the changes; just one minor ask, please change the config property from data_format to format since we use it in other places.

@tarruda tarruda temporarily deployed to integration July 17, 2023 02:10 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:10 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:10 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:10 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to integration July 17, 2023 02:13 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:13 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:13 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:13 — with GitHub Actions Inactive
@tarruda
Copy link
Author

tarruda commented Jul 17, 2023

All good with the changes; just one minor ask, please change the config property from data_format to format since we use it in other places.

renamed the property @edsiper

@tarruda tarruda temporarily deployed to integration July 17, 2023 02:19 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 17, 2023 02:35 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to integration July 18, 2023 00:29 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 18, 2023 00:29 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to pr July 18, 2023 00:29 — with GitHub Actions Inactive
@tarruda tarruda temporarily deployed to integration July 18, 2023 00:35 — with GitHub Actions Inactive
@lecaros
Copy link
Contributor

lecaros commented Jul 19, 2023

@tarruda where's the doc for the new format option? What are the options for this setting?

@tarruda
Copy link
Author

tarruda commented Jul 20, 2023

@tarruda where's the doc for the new format option?

fluent/fluent-bit-docs#1118 I just renamed data_format to format in the docs PR.

What are the options for this setting?

For now it is just "none" (no parsing, the default) and "json". Eventually we might support other formats such as avro

@edsiper edsiper merged commit eeefa81 into fluent:master Jul 20, 2023
43 of 46 checks passed
@martinmajtan
Copy link

martinmajtan commented Jul 21, 2023

Hello,
I tried format option in my configuration and still I got this message:

[2023/07/21 12:01:04] [error] [config] kafka: unknown configuration property 'format'. The following properties are allowed: poll_ms, topics, brokers, client_id, group_id, and rdkafka..

I use this conf:


config:

  inputs: |
    [INPUT]
        Name kafka
        Brokers xxx
        Topics my.topic
        poll_ms 100
        format json

Edit1: Neither format or data_format is not working

@tarruda
Copy link
Author

tarruda commented Jul 21, 2023

@martinmajtan did you compile fluent-bit from latest master? I just ran the kafka_filter example and it is working for me.

@tarruda tarruda deleted the fix-in-kafka-json-parsing branch July 21, 2023 13:12
@martinmajtan
Copy link

martinmajtan commented Jul 21, 2023

@martinmajtan did you compile fluent-bit from latest master? I just ran the kafka_filter example and it is working for me.

I should have mention I'm using Helm chart where I used image version 2.1.7.

@tarruda
Copy link
Author

tarruda commented Jul 21, 2023

@martinmajtan this PR will only be available in version 2.1.8

@anosulchik
Copy link

[2023/08/15 16:15:42] [ info] [fluent bit] version=2.1.8, commit=1d83649441, pid=1
[2023/08/15 16:15:42] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/08/15 16:15:42] [ info] [cmetrics] version=0.6.3
[2023/08/15 16:15:42] [ info] [ctraces ] version=0.3.1
[2023/08/15 16:15:42] [ info] [input:kafka:kafka.0] initializing
[2023/08/15 16:15:42] [ info] [input:kafka:kafka.0] storage_strategy='memory' (memory only)
[2023/08/15 16:15:42] [ info] [input:fluentbit_metrics:fluentbit_metrics.1] initializing
[2023/08/15 16:15:42] [ info] [input:fluentbit_metrics:fluentbit_metrics.1] storage_strategy='memory' (memory only)
[2023/08/15 16:15:42] [error] [config] loki: unknown configuration property 'format'. The following properties are allowed: tenant_id, tenant_id_key, labels, auto_kubernetes_labels, drop_single_key, label_keys, remove_keys, line_format, label_map_path, http_user, http_passwd, and bearer_token.
[2023/08/15 16:15:42] [ help] try the command: /fluent-bit/bin/fluent-bit -o loki -h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kafka Input can't handle json data
8 participants