Enter aggregation results in the index

The goal is to create an Elasticsearch index with only the most recent documents in groups of related documents , in order to keep track of the current state of some control counters and states.

I created a simple Elasticsearch aggregation request :

{ "size": 0, "aggs": { "group_by_monitor": { "terms": { "field": "monitor_name" }, "aggs": { "get_latest": { "top_hits": { "size": 1, "sort": [ { "timestamp": { "order": "desc" } } ] } } } } } } 

He groups related documents into buckets and selects the most recent document for each bucket.

Here are the different ideas that I had to fulfill:

Is there a fairly sophisticated way to accomplish this?

+5
source share
1 answer

Edit the logstash.conf file as follows

 input { elasticsearch { hosts => "localhost" index => "source_index_name" type =>"index_type" query => '{Query}' size => 500 scroll => "5m" docinfo => true } } output { elasticsearch { index => "target_index_name" document_id => "%{[@metadata][_id]}" } } 
+2
source

Source: https://habr.com/ru/post/1246724/


All Articles