# Aggregation not working in Logstash input elasticsearch filter

**URL:** <https://discuss.elastic.co/t/aggregation-not-working-in-logstash-input-elasticsearch-filter/252298>\
**Category:** Logstash\
**Created:** [October 16, 2020, 5:07am UTC](https://discuss.elastic.co/t/aggregation-not-working-in-logstash-input-elasticsearch-filter/252298 "2020-10-16T05:07:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijay\_Barai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijay_barai/32/76087_2.png) [@Vijay\_Barai](https://discuss.elastic.co/u/Vijay_Barai)\
**Post date:** [October 16, 2020, 5:07am UTC](https://discuss.elastic.co/t/aggregation-not-working-in-logstash-input-elasticsearch-filter/252298/1 "2020-10-16T05:07:57Z")

</div>

Hi Team,  
I am trying to do a aggregation using ES query. Query is giving a result in develper tool but when I use it in logstash config file I am not getting a actual result. I am getting only few selected field, at least I expect all the selected fields. Where as I observed that filter primary\_market= "XY" and c\_id="LS" working correctly. I am getting only document for that filter but aggregation is not working.

```auto
input {
       elasticsearch {
               hosts => "${ELK_SERVER}"
               index => "idx_20201014"
               user => "${ELK_USER}"
               password => "${ELK_PASS}"
               query => '{"size" : 0,"query" : {"bool" : {"must" : [{"term" : {"market" : {"value" : "XY"}}},
                                           {"term" : {"c_id" : {"value" : "LS"}}}]}},
 "_source" :{ "includes" : ["c_id","market","amount","quantity"]},
 "aggregations" : {"groupby" : {"composite" : {"size" : 10,
        "sources" : [{"c_id_gp" : {"terms" : {"field" : "c_id"}}},
                     {"date_gp" : {"terms" : {"field" : "date"}}},
                     {"market_gp" : {"terms" : {"field" : "market"}}}
                    ]},
      "aggregations" : {"amount_gp" : {"sum" : {"field" : "amount"}},
                        "quantity_gp" : {"sum" : {"field" : "quantity"}}}
    }}}'
       }
 }
 output {
        stdout{}
 }

```

Output I am getting like this which is all the fields from index

```auto
{
    "amount" => 10037.2167,
        "clientid" => "LS"
}
{
    "amount" => 1238.199706,
        "clientid" => "LS"
}

```

---

<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:** [November 13, 2020, 5:08am UTC](https://discuss.elastic.co/t/aggregation-not-working-in-logstash-input-elasticsearch-filter/252298/2 "2020-11-13T05:08:12Z")

</div>

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