"Ruby exception occurred:" ( sometimes occurred and sometimes not)


(Pedro) #1

Hello, I'm using logstash 6.2.4 with jdbc input from mongodb. I can not figure out what the problem might be. Sometimes it runs without giving errors and sometimes it happens to give errors, being that it is the same pipeline without having modified anything.

input {
	jdbc {
		id => "dash_monthly_aggregation_results"
		jdbc_driver_library => "C:\opt\logstash-6.2.4\lib\mongo_jdbc.jar"
		jdbc_driver_class => "com.dbschema.MongoJdbcDriver"
		jdbc_connection_string => "jdbc:mongodb://localhost:27012/eaq"
		jdbc_user => ""
		jdbc_validate_connection => true
		clean_run => false
		record_last_run => true
		#schedule => "*/3 * * * *"
		jdbc_default_timezone => "Brazil/East"
		last_run_metadata_path => "C:\tmp\elastic\dash_monthly_aggregation_results_last_run"
		statement_filepath =>	"C:\opt\logstash-6.2.4\data\statements\dash_monthly_aggregation_results.sql"
	}
}

filter {
	ruby {
		id => "rb_dash_monthly_aggregation_results"
		code => "
			event.get('map').each {|k, v|
				event.set(k, v)
			}
			event.remove('map')
			
			if event.get('[props][within_goal]') == false
				event.set('[props][within_goal_text]', 'Não atendeu a validade estatística/operacional')
			elsif event.get('[props][within_goal]') == true
				event.set('[props][within_goal_text]', 'Atendeu a validade estatística/operacional')
			end
			
			if event.get('[metadata][service]') == '0002'
				event.set('[metadata][service]', '4G')
			elsif event.get('[metadata][service]') == '0001'
				event.set('[metadata][service]', '3G')
			end
			
			case event.get('[props][eventType]')
			when 'scmThroughtput'
				event.set('[props][eventTypeTraduction]', 'Dw/Up')
			when 'scmLatency'
				event.set('[props][eventTypeTraduction]', 'Latência')
			when 'scmJitter'
				event.set('[props][eventTypeTraduction]', 'Jitter')
			when 'scmPacketLoss'
				event.set('[props][eventTypeTraduction]', 'Perda de Pacotes')
			when 'scmAvailability'
				event.set('[props][eventTypeTraduction]', 'Disponibilidade')
			when 'smpThroughtput'
				event.set('[props][eventTypeTraduction]', 'Download e Upload SMP')
			end
			
			_month = Time.parse(event.get('creation_time')).utc.strftime('%-m')
			_year = Time.parse(event.get('creation_time')).utc.strftime('%Y')
			
			case _month
			when '1'
				event.set('month_text', 'Janeiro')
			when '2'
				event.set('month_text', 'Fevereiro')
			when '3'
				event.set('month_text', 'Março')
			when '4'
				event.set('month_text', 'Abril')
			when '5'
				event.set('month_text', 'Maio')
			when '6'
				event.set('month_text', 'Junho')
			when '7'
				event.set('month_text', 'Julho')
			when '8'
				event.set('month_text', 'Agosto')
			when '9'
				event.set('month_text', 'Setembro')
			when '10'
				event.set('month_text', 'Outubro')
			when '11'
				event.set('month_text', 'Novembro')
			when '12'
				event.set('month_text', 'Dezembro')
			end
			
			_props = ['019', '020', '022', '023', '026', '027', '029', '031', '032', '039', '040', '041', '042', '054', '055', '056', '057', '058', '059', '060'];
			_props.each { |p|
				_field = '[props][' + _year + '][' + _month + '][' + p + ']';
				_newField = 'smp_props_' + p;
				if (event.get(_field)) 
					event.set(_newField, event.get(_field).to_f)
				else
					event.set(_newField, '0'.to_f)
				end
				
				event.remove(_field)
			}
			
			_provider_name = event.get('[metadata][isp]');
			event.set('smp_provider_name', _provider_name );
			event.set('scm_provider_name', _provider_name);
			_month = Time.parse(event.get('creation_time')).utc.strftime('%m')
			_creation_year_month = _year + '/' + _month;
			event.set( 'creation_year_month', _creation_year_month )
		"
	}
	
	mutate {
		gsub => ["creation_time", "BRT", "-03:00"]
		gsub => ["creation_time", "BRST", "-02:00"]
		rename => ["_id" , "id"]
		uppercase => [ "[metadata][isp]" ]
		uppercase => [ "smp_provider_name" ]
		uppercase => [ "scm_provider_name" ]
		remove_field => ["tags"]
	}
	date {
		match => [ "creation_time", "EEE MMM dd HH:mm:ss ZZ yyyy" ]
		target => "creation_time"
	}
}

output {
	elasticsearch { 
	    id => "es_dash_monthly_aggregation_results"
		hosts => ["localhost:9200"]
		index => "dash_monthly_aggregation_results"
		document_id => "%{creation_time}%{cpeid}%{[props][eventType]}"
	}
	stdout { codec => rubydebug }
}

And the error shows nothing:

[2018-07-04T10:50:51,943][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,946][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,947][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,947][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,948][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,948][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,949][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,949][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,950][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,951][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,951][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,953][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,954][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,955][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,960][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,961][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,961][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,962][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,962][ERROR][logstash.filters.ruby ] Ruby exception occurred:
[2018-07-04T10:50:51,963][ERROR][logstash.filters.ruby ] Ruby exception occurred:


(system) #2

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