# Aggregation task\_id

**URL:** <https://discuss.elastic.co/t/aggregation-task-id/107720>\
**Category:** Logstash\
**Created:** [November 15, 2017, 10:26am UTC](https://discuss.elastic.co/t/aggregation-task-id/107720 "2017-11-15T10:26:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [November 15, 2017, 10:26am UTC](https://discuss.elastic.co/t/aggregation-task-id/107720/1 "2017-11-15T10:26:07Z")

</div>

I am trying to project the task\_id to be part of my index name or to have it as fields in the aggregated events.

I try to have it as %{[task\_id]} or some other forms, but without success.

Any idea how to be able to expose it?

My Grok filter is:

```
            grok {
                  break_on_match => true
                  keep_empty_captures => false
                  match => {
                       message => [
                             "%{NUMBER:threadid};%{TIMESTAMP_ISO8601:eventutctime};%{DATA:username};%{JAVACLASS:apiname};%{WORD:apireturnstatus};%{WORD:componentname};%{BASE10NUM:customisation-level};%{BASE10NUM:cputimeinmillisec};%{WORD:runmode};%{WORD:errorcodeiffailure}",
                             "%{NUMBER:threadid};%{TIMESTAMP_ISO8601:eventutctime};%{DATA:username};%{JAVACLASS:apiname};%{WORD:apireturnstatus};%{WORD:componentname};%{BASE10NUM:customisation-level};%{BASE10NUM:cputimeinmillisec};%{WORD:runmode};\(%{GREEDYDATA:errorcodeiffailure}\)\s*%{GREEDYDATA:error_description}"
                       ]
                  }
                 patterns_dir => "C:\DoLense\Patterns\patterns"
            }

```

My aggregation filter is:

```
                  aggregate {
                          task_id => "%{inputserver}_%{exceptiontype}_%{apiname}"
                          code => " map['totalProcessTime'] ||= 0;
                                    map['counter'] ||= 0;
                                    map['counter'] += 1;
                                    map['totalProcessTime'] += event.get('cputimeinmillisec') 
                          "
                          push_map_as_event_on_timeout => true
                          timeout => 50
                          timeout_tags => ['_aggregatetimeout']
                          timeout_code => "event.set('avgProcessTime' , ( event.get('totalProcessTime') / event.get('counter') ) );
                                           event.set('aggregation' , 'true');
                                           event.set('entity' , 'cmserver');

```

# event.set('aggregationfields' , '(event.get('inputserver')\_event.get('exceptiontype')\_event.get('apiname') )' );

```
                                          "
                  } # aggregate

```

My aggregation output is:

```
     if [aggregation] == "true" {
           elasticsearch {
                 hosts => ["localhost:9200"]
                 index => "logstashaggregation%{[entity]}%{+YYYY.MM.dd}"
           }
           stdout { codec => rubydebug }
     }

```

Thanks  
Sharon.

---

<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 13, 2017, 10:26am UTC](https://discuss.elastic.co/t/aggregation-task-id/107720/2 "2017-12-13T10:26:22Z")

</div>

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