logger_logstash_backend icon indicating copy to clipboard operation
logger_logstash_backend copied to clipboard

How to add a metadata as top level property X instead of fields.X?

Open ahmadferdous opened this issue 7 years ago • 1 comments

When I do logger.info("something interesting", meta: "meta_value"), I see on logstash meta property is placed inside fields i.e. fields.meta:

logstash-fields meta

Is it possible to have that property meta as a top level property like host, message and type?

ahmadferdous avatar Sep 22 '17 19:09 ahmadferdous

Indeed , a strong and valid point (which we came across today). Other solutions do not add the 'fields' key and standarising data across platforms is a nice to have. we have modified

https://github.com/marcelog/logger_logstash_backend/blob/master/lib/logger_logstash_backend.ex#L73

to do the following:

 {:ok, json} = JSX.encode Map.merge(%{
      type: type,
      "@timestamp": Timex.format!(ts, "%FT%T%z", :strftime),
      message: to_string(msg),
    }, fields)

more than happy to make a pull request but will break backward compatibility 😄 @ahmadferdous ^^ 👍

stonehz avatar Dec 19 '17 16:12 stonehz