# Duplication while logs are appended in Filebeat

**URL:** <https://discuss.elastic.co/t/duplication-while-logs-are-appended-in-filebeat/277016>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [June 25, 2021, 6:32am UTC](https://discuss.elastic.co/t/duplication-while-logs-are-appended-in-filebeat/277016 "2021-06-25T06:32:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![connectgeeks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/connectgeeks/32/90595_2.png) [@connectgeeks](https://discuss.elastic.co/u/connectgeeks)\
**Post date:** [June 25, 2021, 6:32am UTC](https://discuss.elastic.co/t/duplication-while-logs-are-appended-in-filebeat/277016/1 "2021-06-25T06:32:05Z")

</div>

I'm using Filebeat-\> Logstash-\> ES setup. 7.x  
While paring the apache and json logs using, I notice every time the file is appended with new logs I see old logs also getting re-created in elasticsearch. How can I avoid that.  
So if my json was this initially. it will write 2 records in ES  
sample.json

```auto
{line11: line11, key11: value11, key12: value12}
{line21: line21, key21: value21, key22: value22}

```

Later if 3rd record is appended, it is re-writing the all 3 record in ES while I need only the last one.

```auto
{line11: line11, key11: value11, key12: value12}
{line21: line21, key21: value21, key22: value22}
{line31: line31, key31: value31, key32: value32}

```

filebeat.yaml

```auto
- type: log
  enabled: true
  paths:
    - /var/folder1/*
  scan_frequency: 10s
  ignore_older: 4h
  tags: ["jsonlogs"]

```

logstash.conf

```auto
input {
    beats {
            type => "sample"
            port => "5044"
    }
}
filter {  
if "jsonlogs" in [tags]
  {
  json {
    source => "message"
    }
  mutate {
    remove_field => ["message"]
    add_field => { "hostname" => "my-server" }
    }
  }
}
output {
  stdout {
    codec => rubydebug
  }
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "my-index"
  }
}

```

How can I avoid duplicate on appending the logs ?

---

<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 23, 2021, 8:32am UTC](https://discuss.elastic.co/t/duplication-while-logs-are-appended-in-filebeat/277016/2 "2021-07-23T08:32:12Z")

</div>

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