Logstash - Nested aggregation

Hey,

I am trying to aggregate some data from a SQL DB with Logstash. The data that I am trying to import has the following structure:

  • Category
    • Type
      • Product

Where each category can have multiple types, and each type can have multiple products

The data is read line by line as:
categoryid | categoryname | typeid | typename | productid | productname

The code I currently have is as follows:

filter {
 aggregate {
   task_id => "%{categoryid}"
   code => "
	 map['categoryid'] = event.get('categoryid')
	 map['categoryname'] = event.get('categoryname')
	 map['types'] ||= []
	 map['types'] << {
		'typeid' => event.get('typeid'),
		'typename' => event.get('typename'),
	 }
	map['types']['products'] ||= []
	map['types']['products']  << {
		'productid' => event.get('productid'),
        'productname' => event.get('productname')
	}
	
	 event.cancel()
   "
   push_previous_map_as_event => true
   timeout => 3
 }
}

Unfortunately, this code doesn't work and gives a 'String to Integer' conversion error

I've been searching for help around, but can't seem to find an answer that works.
Thanks in advance!

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