# Logstash aggregate task

**URL:** <https://discuss.elastic.co/t/logstash-aggregate-task/288348>\
**Category:** Logstash\
**Created:** [November 3, 2021, 4:40pm UTC](https://discuss.elastic.co/t/logstash-aggregate-task/288348 "2021-11-03T16:40:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rosboc](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@rosboc](https://discuss.elastic.co/u/rosboc)\
**Post date:** [November 3, 2021, 4:40pm UTC](https://discuss.elastic.co/t/logstash-aggregate-task/288348/1 "2021-11-03T16:40:45Z")

</div>

Hi Team,  
we are using aggregate function to collect all commands for a specific ssh session but recently our vendor changed the way to track session records and right now only start and stop records have the same task\_id while before all records inside a session had the same task\_id.  
Does exit a way to work on the aggregate task to circumvent this ?  
Thanks

```auto
Sep 28 10:36:26 10.143.137.30 **rosboccia** ssh xxxxxxx start task_id=359 start_time=1632825418 timezone=UTC
Sep 28 10:36:32 10.143.137.30 **rosboccia** pts/0 xxxxxxx stop task_id=177959 stop_time=1632825424 service=shell protocol=op-mode cmd=show cmd-arg=interfaces
Sep 28 10:36:51 10.143.137.30 **rosboccia** pts/1 unknown s top task_id=177970 stop_time=1632825443 service=shell protocol=conf-mode cmd=show
Sep 28 10:36:51 10.143.137.30 **rosboccia** pts/0 xxxxx stop task_id=177971 stop_time=1632825443 service=shell protocol=op-mode cmd=show cmd-arg=configuration cmd-arg=commands
Sep 28 10:37:54 10.143.137.30 **rosboccia** ssh xxxxxx stop task_id=359 stop_time=1632825506 timezone=UTC

```

aggregate {  
task\_id =\> "%{vyatta\_ip}-%{task\_id}"  
code =\> 'if map["aggregate\_commands"].nil?  
map["aggregate\_commands"] =   
map["user\_name"] = event.get("user\_name")  
map["config\_timestamp"] = event.get("config\_timestamp")  
map["vyatta\_ip"] = event.get("vyatta\_ip")  
map["from\_host"] = event.get("from\_host")  
end  
cmd\_str = event.get("vyatta\_cmd")  
unless cmd\_str.end\_with? "\n"  
cmd\_str = cmd\_str + "\n"  
end  
map["aggregate\_commands"] \<\< cmd\_str  
'  
push\_map\_as\_event\_on\_timeout =\> true  
timeout\_task\_id\_field =\> "task\_id"  
timeout =\> 300 # 5 minutes timeout  
timeout\_tags =\> ['\_aggregatetimeout']  
}

---

<div class="post-metadata">

**Author:** ![rosboc](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@rosboc](https://discuss.elastic.co/u/rosboc)\
**Post date:** [November 4, 2021, 7:58am UTC](https://discuss.elastic.co/t/logstash-aggregate-task/288348/2 "2021-11-04T07:58:45Z")

</div>

@Badger may i have your opinion on this ?  
Thank you

---

<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:** [November 4, 2021, 3:39pm UTC](https://discuss.elastic.co/t/logstash-aggregate-task/288348/3 "2021-11-04T15:39:27Z")

</div>

An aggregate filter requires a field that is common to all of the events that you want to aggregate. You do not seem to have that, so aggregate will not work.

---

<div class="post-metadata">

**Author:** ![rosboc](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@rosboc](https://discuss.elastic.co/u/rosboc)\
**Post date:** [November 4, 2021, 4:06pm UTC](https://discuss.elastic.co/t/logstash-aggregate-task/288348/4 "2021-11-04T16:06:09Z")

</div>

I expected this answer !  
Thank you very much for the confirmation.

---

<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:** [December 2, 2021, 4:06pm UTC](https://discuss.elastic.co/t/logstash-aggregate-task/288348/5 "2021-12-02T16:06:15Z")

</div>

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