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

Multiple field mappings not supported? #52

Closed
Dom-nik opened this issue Nov 2, 2016 · 3 comments
Closed

Multiple field mappings not supported? #52

Dom-nik opened this issue Nov 2, 2016 · 3 comments
Assignees

Comments

@Dom-nik
Copy link

Dom-nik commented Nov 2, 2016

  • Version: Logstash 5.0, not sure how to check the plugin version
  • Operating System: CentOS 7
  • Config File (if you have sensitive info, please remove it): details below
  • Sample Data: taken from here

Hello,
I tried to setup the plugin to handle multiple field mappings and it fails, mostly returning an #<TypeError: can't convert nil into String>} error.

I tested a couple of versions of config file. For debugging purposes I introduced some extra logging in the loop that parses the fields array:

@fields.each do |old_key, new_key|
        @logger.warn("Keys:", :old_key => old_key, :new_key => new_key) # MY CODE HERE ;]

Here are the fragments of the config file that I tried along with log lines they produce:

  1. fields => [{"date" => "new_date"}, {"title" => "new_title"}]

`[2016-11-02T16:20:44,381][WARN ][logstash.filters.elasticsearch] Keys: {:old_key=>{"date"=>"new_date"}, :new_key=>nil}

  1. fields => ["date", "title"]

[2016-11-02T16:24:01,173][WARN ][logstash.filters.elasticsearch] Keys: {:old_key=>"date", :new_key=>nil}

  1. fields => [{"date" => "new_date", "title" => "new_title"}]
    returns an error:

[ERROR][logstash.agent ] fetched an invalid config

To prove that querying ES works, I can assure that my case works for a single field config like this: fields => {"date" => "new_date"}, basically a replica of the config provided in the plugin docs.

@dejwoo
Copy link

dejwoo commented Nov 24, 2016

Hey @Dom-nik, I have just spent hour trying to get this thing done, and right syntax to use is
fields => [["from","to"],["from","to"],["from","to"],["from","to"]]

@Dom-nik
Copy link
Author

Dom-nik commented Nov 24, 2016

Thank you a lot @dejwoo!
Do you know how can I add this to the docs?

@webmat webmat mentioned this issue May 1, 2018
4 tasks
@webmat
Copy link
Contributor

webmat commented May 1, 2018

Sorry for the delay here.

Yeah Hash notation in Logstash configs is somewhat Ruby-like, which can cause confusion. It's documented here.

Some hash examples are:

attr => {
  "key1" => "value1"
  "key2" => "value2"
}

Or single line (notice there's no comma):

attr => { "key1" => "value1" "key2" => "value2" }

And tuples work as well, as @dejwoo pointed out.

@webmat webmat closed this as completed May 1, 2018
@webmat webmat self-assigned this May 2, 2018
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

3 participants