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

tag_key doesn't work when sending json array to http input #9589

Closed
imankurpatel000 opened this issue Nov 13, 2024 · 1 comment · Fixed by #9590
Closed

tag_key doesn't work when sending json array to http input #9589

imankurpatel000 opened this issue Nov 13, 2024 · 1 comment · Fixed by #9590

Comments

@imankurpatel000
Copy link
Contributor

imankurpatel000 commented Nov 13, 2024

Bug Report

Describe the bug
tag_key doesn't work when sending json array to http input.

To Reproduce

  • Run fluent-bit with the following configuration.

    [INPUT]
        name http
        listen 0.0.0.0
        port 8888
        tag_key key1
    
    [OUTPUT]
        name stdout
        match *
    
    fluent-bit -c fluent-bit.conf 
  • send a json array to http://localhost:8888

    curl -d '[{"key1":"value1","key2":"value2"}]' -XPOST -H "content-type: application/json" http://localhost:8888
  • View the output

    [0] http.0: [[1731488968.157629000, {}], {"key1"=>"value1", "key2"=>"value2"}]
    

    As you can see it didn't tag the record as value1 and instead it falls back to the default tag of http.0

  • Now, send a json object to http://localhost:8888

    curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888

    and now the output is

    [0] value1: [[1731488986.817626000, {}], {"key1"=>"value1", "key2"=>"value2"}]
    

Expected behavior
It should tag the record properly as per the provided tag_key regardless if the data is sent as json object or array of json objects.

Your Environment

  • Version used: 3.1.0

Additional context
The issue was introduced by #8794 which I believe was merged in 3.0.7 and 3.1.0. The issue is simple mistake of not setting the value of tag_from_record variable in the else block here.

@milon619
Copy link

milon619 commented Nov 25, 2024

Any chance this can be reviewed and bugfix available in a release? This is kind of blocking from going to the latest version of FluentBit.

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

Successfully merging a pull request may close this issue.

2 participants