# Logstash Aggregation

**URL:** <https://discuss.elastic.co/t/logstash-aggregation/87583>\
**Category:** Logstash\
**Created:** [May 30, 2017, 2:37pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583 "2017-05-30T14:37:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![NounouGeek](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@NounouGeek](https://discuss.elastic.co/u/NounouGeek)\
**Post date:** [May 30, 2017, 2:37pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/1 "2017-05-30T14:37:45Z")

</div>

Hello,

I would like to know how to create an index from an existing Index with Elasticsearch aggregations. (In my case, i would like to get statistics per login: count\_connection, distinct\_count\_connection, first\_connection, last\_connection in new index or csv output).

I use ELK 5.4

Thank you in advance

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [May 30, 2017, 2:49pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/2 "2017-05-30T14:49:37Z")

</div>

Rather than Logstash, you're probably better off asking in the Elasticsearch forum about how to use the [Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-reindex.html) to do this with a query in the reindex API call.

---

<div class="post-metadata">

**Author:** ![NounouGeek](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@NounouGeek](https://discuss.elastic.co/u/NounouGeek)\
**Post date:** [May 30, 2017, 3:45pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/3 "2017-05-30T15:45:19Z")

</div>

Thanks for reply. Reindex API it's only for dump current index into new Index.  
In index 1 I've all data connections per day, and I would like to create an index 2 from aggregations of Index 1 (one line per login "email", with all informations "count connection, date last connexion, .....")

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [May 30, 2017, 6:35pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/4 "2017-05-30T18:35:20Z")

</div>

You should re-read the link I sent you. The Reindex API, while it can "dump" an index into a new one, it's much more sophisticated than just that use case. It also allows you to use the results of a query to populate a new index:

```auto
POST _reindex
{
  "source": {
    "index": "twitter",
    "type": "tweet",
    "query": {
      "term": {
        "user": "kimchy"
      }
    }
  },
  "dest": {
    "index": "new_twitter"
  }
}

```

So, why not try aggregations in a reindex with a query?

---

<div class="post-metadata">

**Author:** ![NounouGeek](https://avatars.discourse-cdn.com/v4/letter/n/cc9497/32.png) [@NounouGeek](https://discuss.elastic.co/u/NounouGeek)\
**Post date:** [May 31, 2017, 8:26am UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/5 "2017-05-31T08:26:03Z")

</div>

Could you please give me an example of query syntax with aggs inside query?

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [May 31, 2017, 4:18pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/6 "2017-05-31T16:18:28Z")

</div>

That question definitely belongs in the Elasticsearch section of the forums.

---

<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:** [June 28, 2017, 4:18pm UTC](https://discuss.elastic.co/t/logstash-aggregation/87583/7 "2017-06-28T16:18:31Z")

</div>

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