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

Open
imankurpatel000 opened this issue Nov 13, 2024 · 0 comments · May be fixed by #9590
Open

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

imankurpatel000 opened this issue Nov 13, 2024 · 0 comments · May be fixed by #9590

Comments

@imankurpatel000
Copy link

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.

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.

1 participant