# Data missing with logstash elasticsearch-input-plugin

**URL:** <https://discuss.elastic.co/t/data-missing-with-logstash-elasticsearch-input-plugin/222327>\
**Category:** Logstash\
**Created:** [March 5, 2020, 3:09pm UTC](https://discuss.elastic.co/t/data-missing-with-logstash-elasticsearch-input-plugin/222327 "2020-03-05T15:09:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![higee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/higee/32/22343_2.png) [@higee](https://discuss.elastic.co/u/higee)\
**Post date:** [March 5, 2020, 3:09pm UTC](https://discuss.elastic.co/t/data-missing-with-logstash-elasticsearch-input-plugin/222327/1 "2020-03-05T15:09:31Z")

</div>

Hi,

I was using Logstash (7.4.2) to transfer documents between Elasticsearch indices (7.4.2). First have a look at the Logstash.conf

```auto
input {
  elasticsearch {
    hosts => ""
    index => "haproxy-*"
    scroll => "10m"
    size => 10000
    query => '{
      "_source" : [
        "@timestamp", "http_status_code", 
       "request_header_forwarded_for", "http_verb",
      "request_header_user_agent"
      ],
      "query" : {
        "bool" : {
          "must": [
            {"exists": {"field": "request_header_user_agent"}},
            {"exists": {"field": "r_time"}},
          ],
          "must_not" : [
            {"term": {"http_status_code": "417"}}
          ]
        }
      }
    }'
  }
}

filter {
  mutate {
    add_field => { "target_index" => "%{[@metadata][_index]}" }
  }
  mutate {
    gsub => [
      "target_index", "service_a_haproxy_", "service_a_copy_haproxy_"
    ]
    remove_field => ["@version"]
  }
}

output {
  elasticsearch {
    hosts => ""
    index => "%{target_index}"
    document_id => "%{[@metadata][_id]}"
  }
}

```

As you can see I'm inheriting index and document ID of the source indices. For instance,  
the `service_a_haproxy-2020.02.01` index becomes `service_a_copy_haproxy_2020.02.01` and document ID stays the same to be consistent between indices.

However, when I checked the result, there was a gap in the number of documents between source and target indices.

- Source  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/812fb7c9e2b5b1c98d3c14677a9c15138d49dad5.png)

- Target  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/8/38d31a94aa6c707bf93de4d60960060a44bb3d62.png)

Anyone has an idea what went wrong?

---

<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:** [April 2, 2020, 3:09pm UTC](https://discuss.elastic.co/t/data-missing-with-logstash-elasticsearch-input-plugin/222327/2 "2020-04-02T15:09:31Z")

</div>

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