# Aggregate filter works in Logstash 6.8 but not in 7.4

**URL:** <https://discuss.elastic.co/t/aggregate-filter-works-in-logstash-6-8-but-not-in-7-4/230531>\
**Category:** Logstash\
**Created:** [April 30, 2020, 11:50am UTC](https://discuss.elastic.co/t/aggregate-filter-works-in-logstash-6-8-but-not-in-7-4/230531 "2020-04-30T11:50:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Criss](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Criss](https://discuss.elastic.co/u/Criss)\
**Post date:** [April 30, 2020, 11:50am UTC](https://discuss.elastic.co/t/aggregate-filter-works-in-logstash-6-8-but-not-in-7-4/230531/1 "2020-04-30T11:50:27Z")

</div>

Hello Team,

I have a pipeline with aggregate filter ( with "start event" and "end event"). This pipeline works perfect in logstash version 6.8 and the output contains a map with my values

Output in Logstash 6.8:

```auto
"Checks": [{
		"Check": {
			"data": " Estado de la instancia",
			"result": "OK"
		}
	},
	{
		"Check": {
			"data": " Numero de filesystems criticos por encima del umbral recomendado: 0",
			"result": "OK"
		}
	},
	{
		"Check": {
			"data": " Memoria del servidor 1633(5%) por debajo del 90% del total: 32388",
			"result": "OK"
		}
	},
	{
		"Check": {
			"data": " Conexiones actuales: 20: por debajo del 80% de las maximas: 3256",
			"result": "OK"
		}
	}],
	"@version": "1",
	"Test": "Test",
	"group": "DataBase",
	"servr": "XXXXXXX",
	"app": "XXXXXX",
	"tier": "XXXXXX",
	"@timestamp": "2020-04-30T07:42:01.516Z"
} 

```

Attach my code in pipeline:

```auto
 if [log] =~ /^Script.*/ or [log] =~ /^INICIO.*/ or [log] =~ /^SCRIPT.*/ or [log] =~ /^Inicio.*/ {
      mutate{
         add_field => { "Test" => "Test" }
      }
      aggregate {
          task_id => "%{Test}"
          code =>"
                map['Checks']||= []
                event.cancel()
          "
          map_action => "create"
     }
 } else if [log] =~ /^FIN .*/ or [log] =~ /^Fin .*/ {
       mutate{
          add_field => {"Test" => "Test" }
       }
       aggregate {
          task_id => "%{Test}"
          code => "event.set('Checks',map['Checks'])"
          map_action => "update"
          end_of_task => true
          timeout => 3
       }
 }else if [log] =~ /^OK: .*/ or [log] =~ /^ERROR: .*/ or [log] =~ /^WARNING: .*/ {
       mutate{
          add_field => { "Test" => "Test" }
      }
      mutate {
                split => { "log" => ":" }
                add_field => {"[Check][result]" => "%{[log][0]}" }
      }
      ruby{
          code => "info = event.get('[log]')
                   event.set('[Check][data]',info[1..-1])
                  "
      }
      mutate{
          gsub => [
                  "[Check][data]", "," , ":"
          ]
      }
      mutate{
          join => {"[Check][data]" => ":" }
      }
    aggregate {
       task_id => "%{Test}"
       code => "
                map['Checks'] << {'[Check]' =>event.get('[Check]') }
                event.cancel()
               "
        map_action => "update"
    }

```

However in Logstash version 7.4 or superior my pipeline doesn't work. In my output doesn't appear a map called "Checks". It's like the pipeline doesn't create a map in the start event ( skip this actions map['Checks']||= ; event.cancel() ) or in end event not execute this action ( code =\> "event.set('Checks',map['Checks'])")

Only in one event create a map called Checks but is empty. The other events don't contains a map

Output in Logstash 7.4:

```auto
{
	"absolute_time": "2020-04-29T16:00:41Z",
	"Checks": [], ---- It's empty
	"tier": "XXXXX",
	"@version": "1",
	"app": "XXXXXX",
	"@timestamp": "2020-04-29T16:40:01.484Z",
	"group": "DataBase",
	"Test": "Test",
	"servr": "XXXXX"
}
{
	"absolute_time": "2020-04-29T16:00:42Z",
	"@timestamp": "2020-04-29T16:40:01.484Z",
	"@version": "1",
	"log": "Script chequeo X@XXXX@X@XXX",
	"group": "DataBase",
	"Test": "Test"
}

```

I don't understand why occurs this.

I am grateful for all suggestions

Kind Regards

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 30, 2020, 3:10pm UTC](https://discuss.elastic.co/t/aggregate-filter-works-in-logstash-6-8-but-not-in-7-4/230531/2 "2020-04-30T15:10:06Z")

</div>

This could be because logstash is not maintaining the order of events. Make sure you [disable java\_execution](https://github.com/elastic/logstash/issues/10938) in addition to setting pipeline.workers to 1.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 28, 2020, 3:12pm UTC](https://discuss.elastic.co/t/aggregate-filter-works-in-logstash-6-8-but-not-in-7-4/230531/3 "2020-05-28T15:12:37Z")

</div>

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