If else ruby check for nil


I am using a ruby codeblock to add values from redis for specific cases - I am getting some null values and want to log those - but this check for null values and isn't working, I get a complication error - looking at the docs, I am assuming this is valid ruby:

 key = event.get('apikey')
 if key == nil
       puts event.to_hash
       endpoint = event.get('uripath')

Here is the concatenated error:

Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [ \\t\\r\\n], \"#\", \"{\", \"}\" at line 66, column 19 (byte 2197) after filter {\r\n grok {\r\n match => { \"message\" => '%{SYSLOGTIMESTAMP:syslogtimestamp} %{DATA:Aloha_name} %{DATA:Haproxy_process}: %{DATA:client_ip}:%{INT:client_port} \\[%{HAPROXYDATE:accept_date}\\] %{NOTSPACE:frontend_name} %{NOTSPACE:backend_name}/%{NOTSPACE:server_name} %{INT:Tq}/%{INT:Tw}/%{INT:Tc}/%{INT:Tr}/%{INT:Tt} %{INT:http_status_code} %{NOTSPACE:bytes_read} - - ----

I see no reason to think the ruby filter has anything to do with this. What does your configuration look like?

You are right - I am not sure what it was eventually but I started with a clean file and built up the code... thanks

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