Skip to content

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

Closed
@imankurpatel000

Description

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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions