# In Logstash output elastisearch plugin is there a way to get response code from elastic after insert?

**URL:** <https://discuss.elastic.co/t/in-logstash-output-elastisearch-plugin-is-there-a-way-to-get-response-code-from-elastic-after-insert/236049>\
**Category:** Logstash\
**Created:** [June 6, 2020, 5:42pm UTC](https://discuss.elastic.co/t/in-logstash-output-elastisearch-plugin-is-there-a-way-to-get-response-code-from-elastic-after-insert/236049 "2020-06-06T17:42:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ullas7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ullas7/32/68349_2.png) [@Ullas7](https://discuss.elastic.co/u/Ullas7)\
**Post date:** [June 6, 2020, 5:42pm UTC](https://discuss.elastic.co/t/in-logstash-output-elastisearch-plugin-is-there-a-way-to-get-response-code-from-elastic-after-insert/236049/1 "2020-06-06T17:42:21Z")

</div>

I trying to insert a document in elasticDB using the following logstash output config

```auto
elasticsearch{
			hosts => "localhost:9200"
			index => "indexname"
			document_id => "%{conversationId}"
			# action => "create"
		 
		}

```

I will get a duplicate message from the source. I need to know whether last save was insert or update.

depending on the response from elastic I would like to store duplicate msg another output source.

I tried with ` action => "create"` hoping to catch error response .

I want to handle duplicate message

```auto
 if not duplicate
    insert to elastic
   push to kafka

if duplicate
  update to elastic # this is taken care by document_id
  don't post to kafka

```

Can someone assist me in this?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 6, 2020, 7:04pm UTC](https://discuss.elastic.co/t/in-logstash-output-elastisearch-plugin-is-there-a-way-to-get-response-code-from-elastic-after-insert/236049/2 "2020-06-06T19:04:57Z")

</div>

The elasticsearch output does not provide any status that you can test.

How about using a second pipeline that reads new messages from elasticsearch and writes them to kafka?

---

<div class="post-metadata">

**Author:** ![Ullas7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ullas7/32/68349_2.png) [@Ullas7](https://discuss.elastic.co/u/Ullas7)\
**Post date:** [June 8, 2020, 5:50am UTC](https://discuss.elastic.co/t/in-logstash-output-elastisearch-plugin-is-there-a-way-to-get-response-code-from-elastic-after-insert/236049/3 "2020-06-08T05:50:48Z")

</div>

@Badger thanks for the response. This is exactly what I did. Here I am facing another issue, I put scheduler to pick from EL every 1 minute and write it to Kafka, now the problem is I need to manually update each document as processed(some flag) so that it won't be picked next batch. I need to add a new flag every time I push to Kafka ( two output writes)  
I have another problem 😄 If I update the new document(duplicate) in the first pipeline the flag will be overridden and it will be again picked by the second pipeline.  
This can be avoided by using `action => create`

---

<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 6, 2020, 5:50am UTC](https://discuss.elastic.co/t/in-logstash-output-elastisearch-plugin-is-there-a-way-to-get-response-code-from-elastic-after-insert/236049/4 "2020-07-06T05:50:55Z")

</div>

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