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

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

Open
ahmadferdous opened this issue Sep 22, 2017 · 1 comment
Open

Comments

@ahmadferdous
Copy link

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 ahmadferdous changed the title How to add a metadata as top level property X instead of fields.X How to add a metadata as top level property X instead of fields.X? Sep 22, 2017
@stonehz
Copy link

stonehz commented Dec 19, 2017

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 ^^ 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants