# Write data that have failed in Logstash filter transforms to file

**URL:** <https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649>\
**Category:** Logstash\
**Created:** [January 28, 2022, 5:02am UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649 "2022-01-28T05:02:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GitSpree23](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@GitSpree23](https://discuss.elastic.co/u/GitSpree23)\
**Post date:** [January 28, 2022, 5:02am UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649/1 "2022-01-28T05:02:22Z")

</div>

My logstash config has a filter performing several transformations. But I see many records failing to get processed because of incorrect format/encoding in source data.  
I want Logstash to write these failed inputs to a file, which I can further use to validate data loss and/or improve source data and logstash transforms.

How can I do this currently?

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 28, 2022, 9:34am UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649/2 "2022-01-28T09:34:02Z")

</div>

if you set `log.level` to debug or trace, Logstash write more information about failures to log file. Is it not enough for you?

---

<div class="post-metadata">

**Author:** ![GitSpree23](https://avatars.discourse-cdn.com/v4/letter/g/65b543/32.png) [@GitSpree23](https://discuss.elastic.co/u/GitSpree23)\
**Post date:** [January 29, 2022, 11:43am UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649/3 "2022-01-29T11:43:13Z")

</div>

But using debug I can't identify the ones that have failed. I want to view only the failed messages.

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 29, 2022, 11:59am UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649/4 "2022-01-29T11:59:33Z")

</div>

This post help you?

> [@Logstash Handling Filter Errors](https://discuss.elastic.co/t/logstash-handling-filter-errors/287309/2):
>
> Errors are saved in an array named tags. For example Grok will add \_grokparsefailure to that tag when something happens. Then you can do your error handling from that. if "\_grokparsefailure" in [tags] { # do something } [\_grokparsefailure documentation](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#plugins-filters-grok-tag_on_failure)[\_mutate\_error](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-tag_on_failure) The tag\_on\_failure option is what you are looking for and you can set it to what you want or use the defaults.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [January 29, 2022, 12:38pm UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649/5 "2022-01-29T12:38:33Z")

</div>

You need to share your logstash configuration, show what filters you are using.

Some parser filters, like `grok`, `json`, `kv` and `csv` will add a tag when it fails, other filters do that as well.

---

<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:** [February 26, 2022, 12:39pm UTC](https://discuss.elastic.co/t/write-data-that-have-failed-in-logstash-filter-transforms-to-file/295649/6 "2022-02-26T12:39:30Z")

</div>

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