Can logstash get the type of field?

OK, below is the problem I met.

so, I want to get the type of the field. for example, there are two different type log but with same field:
{"url":"192.168.0.1/test","user":"xiang"}}
{"url":"192.168.0.1/test","user":{"name":"xiang","age":20}}

then I use filter{ { json { source => "message" } } in logstash.
If the type of "user" is string , I save the value in field "user_name", if not ,save the value in field "user".
Do you have any suggest?

1 Like