vjeantet/bitfan

I can't use items of array after mutate split

AlexAkulov opened this issue · 5 comments

Hello!
My usual case is receiving tab-separated line, split, and manipulate items. But in bitfan I can't use items of array after mutate split.

For example:
config:

input {
    stdin {}
}
filter {
    mutate {
        split => {"message" => " "}
    }
    mutate {
        add_field => {
            "one" => "%{message[0]}",
            "two" => "%{message[1]}",
            "three" => "%{message.2}",
            "four" => "%{[message][3]}"
        }
    }
}
output {
  stdout {
     codec => rubydebug { }
  }
}

output:

$ bitfan run
1 2 3 4
{
  "@timestamp": 2017-12-14 13:46:34 Local,
  "tags":       []string{},
  "one":        "[1 2 3 4]",
  "two":        "",
  "three":      "",
  "four":       "",
  "host":       "vm-bitfan1",
  "message":    []string{
    "1",
    "2",
    "3",
    "4",
  },
}

Probably it is specific of "github.com/clbanning/mxj", this library supports only maps but not slices.

I think this is related to a bug on the Split func
Which split and set []string instead of []interface

Mxj knows how to handle []interface

Will fix this

fixed

capture d ecran 2017-12-15 a 00 23 10

Todo : fix tests related to this fix.

Thank you very much!