Ruby filter limitations to hash tables?

Are there any limitations to what you can do with a hash table in the ruby filter? I'm trying things that work well in regular ruby, but which cause logstash --config.test_and_exit to throw an error.
I have searched the forums, and googled in general, but couldn't find anything pointing me in the right direction.

At the start of the code block I try to initialize a hash table (shortened, actually has 60+ elements):
mod_hsh = {
:A => { :aa => "AA", :ab => "AB" },
:B => { :ba => "BA", :bb => "BB" }
I also tried this with a different syntax:
mod_hsh = {}
mod_hsh[:A] = { :aa => "AA", :ab => "AB" }
mod_hsh[:B] = { :ba => "BA", :bb => "BB" }
and I even tried:
mod_hsh = {}
mod_hsh[:A] = [ "AA", "AB" ]
mod_hsh[:B] = [ "BA", "BB" ]
In all three cases logstash --config.test_and_exit gives a message like this:
The given configuration is invalid. Reason: Expected one of #, {, } at line 43, column 21 (byte 1037) after filter {
...(lines skipped)
ruby {
code => "
mod_hsh = {}
mod_hsh[:B] = [ "

Are there limitations to ruby inside the ruby filter code block such as the ruby version, the size or number of elements that are allowed, or that hash elements cannot be arrays or hashes themselves?
As said, the code works fine in a regular ruby environment, so what's wrong with my code?

That error is due to double quote usage inside your code. The parser goes from double quote to double quote and reads the code as

mod_hsh = {}
mod_hsh[:B] = [ 

which of course is invalid.

Either use single quotes for strings inside your code block and double for enclosing your code block or vice versa.

[blush] Oops that is about as noob as it comes, what a silly mistake. Thanks for pointing it out though!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.