# Create an error log with an ingest pipeline when there is an indexing error

**URL:** <https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [December 6, 2021, 4:01pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069 "2021-12-06T16:01:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GinkoLucas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginkolucas/32/107055_2.png) [@GinkoLucas](https://discuss.elastic.co/u/GinkoLucas)\
**Post date:** [December 6, 2021, 4:01pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/1 "2021-12-06T16:01:04Z")

</div>

Hi,  
I would like to create an error log when a document is not suitable for my mapping.

For example if I send a document containing an unknown field in my mapping (dynamic:false), I would like to be able to create an error log in another index.

Is it possible with an ingest pipeline ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 7, 2021, 2:59am UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/2 "2021-12-07T02:59:08Z")

</div>

[Ingest pipelines | Elasticsearch Guide [7.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html#handling-pipeline-failures) touches on that, specifically the `on_failure` parameter.

---

<div class="post-metadata">

**Author:** ![GinkoLucas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginkolucas/32/107055_2.png) [@GinkoLucas](https://discuss.elastic.co/u/GinkoLucas)\
**Post date:** [December 7, 2021, 10:21am UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/3 "2021-12-07T10:21:33Z")

</div>

Okay, thx for the doc.  
But the on\_failure parameter work with a processor, which one can i use ?  
I just want to test the incoming documents, et create an error when a field is unknow.

---

<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:** [December 7, 2021, 1:37pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/4 "2021-12-07T13:37:24Z")

</div>

Unless there is something not well explained in the documentation, I don't think it is possible.

The `on_failure` parameter applies to errors on processors in the ingest pipeline, it allows you to deal with errors during the ingest pipeline processing, the mapping error will happen after that phase, when Elasticsearch tries to index it.

---

<div class="post-metadata">

**Author:** ![GinkoLucas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginkolucas/32/107055_2.png) [@GinkoLucas](https://discuss.elastic.co/u/GinkoLucas)\
**Post date:** [December 7, 2021, 1:53pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/5 "2021-12-07T13:53:04Z")

</div>

Okay,

So there is no way to know if a document has an unknown field before indexing it ?  
With an ingest pipeline if possible.

---

<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:** [December 7, 2021, 2:01pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/6 "2021-12-07T14:01:36Z")

</div>

Maybe you can use the script processor to write a painless script that will test each field and see if they are in a list of allowed fields, but I do not have experience with painless script to know how you can do that.

But I don't think this is something easy to do, and also it can impact the performance.

---

<div class="post-metadata">

**Author:** ![GinkoLucas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginkolucas/32/107055_2.png) [@GinkoLucas](https://discuss.elastic.co/u/GinkoLucas)\
**Post date:** [December 8, 2021, 3:12pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/7 "2021-12-08T15:12:48Z")

</div>

Thanks, this is a good idea.

I searched how to get the field names of the documents, in painless, but no result.  
If you know how to do this...

---

<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:** [January 5, 2022, 3:13pm UTC](https://discuss.elastic.co/t/create-an-error-log-with-an-ingest-pipeline-when-there-is-an-indexing-error/291069/8 "2022-01-05T15:13:02Z")

</div>

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