# Aggregation does not work

**URL:** <https://discuss.elastic.co/t/aggregation-does-not-work/161613>\
**Category:** Logstash\
**Created:** [December 20, 2018, 2:45am UTC](https://discuss.elastic.co/t/aggregation-does-not-work/161613 "2018-12-20T02:45:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmkim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmkim/32/37997_2.png) [@jmkim](https://discuss.elastic.co/u/jmkim)\
**Post date:** [December 20, 2018, 2:45am UTC](https://discuss.elastic.co/t/aggregation-does-not-work/161613/1 "2018-12-20T02:45:17Z")

</div>

Hi, everyone!

I am trying to figure out the log count by device.

There is an error  
No data accumulates in the Elastic Search.

```
aggregate {
  task_id => "%{device}"
  code => "
    map['log_cnt'] ||= 0
    map['log_cnt'] += 1
    event.cancel()
  "
  push_map_as_event_on_timeout => true
  timeout_task_id_field => "device"
  timeout_timestamp_field => "@timestamp"
  timeout => 100
  inactivity_timeout => 60
  timeout_tags => ['_aggregatetimeout']
  timeout_code => "event.set('several_cnt', event.get('log_cnt') > 1)"
}

```

Can you help me?

---

<div class="post-metadata">

**Author:** ![jmkim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmkim/32/37997_2.png) [@jmkim](https://discuss.elastic.co/u/jmkim)\
**Post date:** [December 20, 2018, 6:35am UTC](https://discuss.elastic.co/t/aggregation-does-not-work/161613/2 "2018-12-20T06:35:12Z")

</div>

I solved the problem.

I've created multiple indexes through different types of filters.

I created aggregate-only index through aggregate plugin and it output normally.

I do not know what it is.  
But, it is fine

```
aggregate {
  task_id => "%{device}"
  push_map_as_event_on_timeout => true
  timeout_task_id_field => "device" 
  timeout_timestamp_field => "@timestamp" 
  timeout => 100
  inactivity_timeout => 60
  code => "
    map['log_cnt'] ||= 0
    map['log_cnt'] += 1
    event.cancel if map['pre_log_tm'] && map['pre_log_tm'] >= (event.get('log_tm') - 240)
  "
  timeout_tags => ['_aggregatetimeout']
  timeout_code => "event.set('log_type', 'rename')"
}
```

---

<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:** [January 17, 2019, 6:35am UTC](https://discuss.elastic.co/t/aggregation-does-not-work/161613/3 "2019-01-17T06:35:13Z")

</div>

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