# Another elasticsearch aggregation query question

**URL:** <https://discuss.elastic.co/t/another-elasticsearch-aggregation-query-question/90197>\
**Category:** Elasticsearch\
**Created:** [June 21, 2017, 5:33am UTC](https://discuss.elastic.co/t/another-elasticsearch-aggregation-query-question/90197 "2017-06-21T05:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xwang12345](https://avatars.discourse-cdn.com/v4/letter/x/49beb7/32.png) [@xwang12345](https://discuss.elastic.co/u/xwang12345)\
**Post date:** [June 21, 2017, 5:33am UTC](https://discuss.elastic.co/t/another-elasticsearch-aggregation-query-question/90197/1 "2017-06-21T05:33:31Z")

</div>

I have the documents with the following 5 tuples:

session meta data:  
src\_ip, src\_port, dst\_ip, dst\_port, proto, hostname

session stats data:  
src\_ip, src\_port, dst\_ip, dst\_port, proto, in\_bytes, out\_bytes.

For each document of session meta data, there will be several session stats data documents

I would like to aggregate on the hostname, with the total in+out bytes for each host.

It is like one meta data document with many stats documents, the key to join them is the 5 tuple, could someone give me some hints how to aggregate it?

Example will be highly appreciated,

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 21, 2017, 6:12am UTC](https://discuss.elastic.co/t/another-elasticsearch-aggregation-query-question/90197/2 "2017-06-21T06:12:23Z")

</div>

If it is a tuple you regularly aggregate across, it might make sense to create a separate field at ingest time that contains it, e.g. by concatenating the fields.

---

<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:** [July 19, 2017, 6:12am UTC](https://discuss.elastic.co/t/another-elasticsearch-aggregation-query-question/90197/3 "2017-07-19T06:12:24Z")

</div>

Closed on July 19, 2017, 6:12am UTC

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