# Is there a way to dump data in a file if logstash fails to dump the data in elasticsearch for a particular run

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-dump-data-in-a-file-if-logstash-fails-to-dump-the-data-in-elasticsearch-for-a-particular-run/313134>\
**Category:** Logstash\
**Created:** [August 29, 2022, 8:31am UTC](https://discuss.elastic.co/t/is-there-a-way-to-dump-data-in-a-file-if-logstash-fails-to-dump-the-data-in-elasticsearch-for-a-particular-run/313134 "2022-08-29T08:31:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anand\_tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_tripathi/32/107286_2.png) [@anand\_tripathi](https://discuss.elastic.co/u/anand_tripathi)\
**Post date:** [August 29, 2022, 8:31am UTC](https://discuss.elastic.co/t/is-there-a-way-to-dump-data-in-a-file-if-logstash-fails-to-dump-the-data-in-elasticsearch-for-a-particular-run/313134/1 "2022-08-29T08:31:02Z")

</div>

I am using Logstash to dump my data from Postgres to Elasticsearch. So the input is JDBC that is fetching data from Postgres using tracking\_column and let's say for one run it is taking 1000 records from Postgres

Output is Elasticsearch and it is dumping those 1000 records in Elasticsearch. So if there is an error while dumping data to Elasticsearch logstash got some error lets Elasticsearch node is unreachable due to some reason then logstash is just incrementing to the next run.

I want to know is there some way I can rerun the same run if there is some error or at least dump the data into some file so that I can run it manually afterwards.

---

<div class="post-metadata">

**Author:** ![Shaoranlaos](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Shaoranlaos](https://discuss.elastic.co/u/Shaoranlaos)\
**Post date:** [August 29, 2022, 9:26am UTC](https://discuss.elastic.co/t/is-there-a-way-to-dump-data-in-a-file-if-logstash-fails-to-dump-the-data-in-elasticsearch-for-a-particular-run/313134/2 "2022-08-29T09:26:36Z")

</div>

You could use the Dead letter queue for this:

> **[Dead letter queues (DLQ) | Logstash Reference \[8.4\] | Elastic](https://www.elastic.co/guide/en/logstash/8.4/dead-letter-queues.html)**

This automatically dumps events that were not successfully sent to ES into a file and you can then use a special input to do something with these events (e.g. write them into a file or sent them to someone via mail).

---

<div class="post-metadata">

**Author:** ![anand\_tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_tripathi/32/107286_2.png) [@anand\_tripathi](https://discuss.elastic.co/u/anand_tripathi)\
**Post date:** [August 29, 2022, 9:42am UTC](https://discuss.elastic.co/t/is-there-a-way-to-dump-data-in-a-file-if-logstash-fails-to-dump-the-data-in-elasticsearch-for-a-particular-run/313134/3 "2022-08-29T09:42:10Z")

</div>

Thanks, this is what I was looking for.

---

<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:** [September 26, 2022, 9:42am UTC](https://discuss.elastic.co/t/is-there-a-way-to-dump-data-in-a-file-if-logstash-fails-to-dump-the-data-in-elasticsearch-for-a-particular-run/313134/4 "2022-09-26T09:42:11Z")

</div>

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