logstash-plugins / logstash-filter-mutate

Apache License 2.0
16 stars 75 forks source link

mutate convert "int" causes ungraceful crash #31

Open jordansissel opened 9 years ago

jordansissel commented 9 years ago

(This issue was originally filed by @weaseal at https://github.com/elastic/logstash/issues/3197)


I added this in a logstash config file (notice "int", not integer, thanks to torrancew on irc for catching my error):

mutate {
  convert => [ "disk_read", "int" ]
  convert => [ "disk_write", "int" ]
}

Then when when restarting logstash, it crashes with this error:

$ cat logstash.stdout 
Sending logstash logs to /var/log/logstash/logstash.log.
+---------------------------------------------------------+
| An unexpected error occurred. This is probably a bug.   |
| You can find help with this problem in a few places:    |
|                                                         |
| * chat: #logstash IRC channel on freenode irc.          |
|     IRC via the web: http://goo.gl/TI4Ro                |
| * email: logstash-users@googlegroups.com                |
| * bug system: https://logstash.jira.com/                |
|                                                         |
+---------------------------------------------------------+
The error reported is: 
  undefined local variable or method `valid_types' for #<LogStash::Filters::Mutate:0x5d9d6359>

Changing "int" to "integer" fixed the issue.

This is on RHEL 7:

$ sudo yum list installed | grep logstash
logstash.noarch            1.4.2-1_2c0f5a1     @logstash-1.4
purbon commented 9 years ago

Actually there is an expected behaviour to raise a configuration exception when using a non valid type as you can see https://github.com/logstash-plugins/logstash-filter-mutate/blob/master/spec/filters/mutate_spec.rb#L16-L26 and https://github.com/logstash-plugins/logstash-filter-mutate/blob/master/lib/logstash/filters/mutate.rb#L181-L188

and the value there is integer, not int.

What was your expectation @weaseal ? I guess obviously that LS does not crash, I will check this behaviour now and report here.

purbon commented 9 years ago

I tested this with an ubuntu machine and the last release of the package. The behaviour this days logstash does not blow up like reported, but output a message like:

vagrant@vagrant-ubuntu-trusty-64:~$ cat /var/log/logstash/logstash.log 
{:timestamp=>"2015-09-08T10:23:14.703000+0000", :message=>"Error: Cannot register filter mutate plugin. The error reported is: \n  Invalid conversion type 'int', expected one of 'string,integer,float,boolean'"}
{:timestamp=>"2015-09-08T10:23:14.715000+0000", :message=>"You may be interested in the '--configtest' flag which you can\nuse to validate logstash's configuration before you choose\nto restart a running system."}

indicating that there is a problem with the configuration.

I guess the open question here is, should we support int also as a type? or keep only integer?

@jordansissel @weaseal what do you think?

weaseal commented 9 years ago

Your sample out put looks much better than what I experienced originally. Looks good to me. Thanks

purbon commented 9 years ago

Closing this as the motivation of this has been arranged in recent versions. will open another issue to track different type names.

magnusbaeck commented 7 years ago

@purbon, it looks like you intended to close this issue but ended up not closing it. If you didn't intend to close it, what remains to be done?