# Elasticsearch output plugin does not write to elasticsearch

**URL:** https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401
**Category:** Logstash
**Created:** [September 21, 2017, 10:57pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401 "2017-09-21T22:57:47Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)
#### Post date: [September 21, 2017, 10:57pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/1 "2017-09-21T22:57:47Z")

</div>

Hello!

I've just upgraded logstash from 2.2 to 5.5. I have the current version of the elasticsearch output plugin installed (8.8.2)

Logstash no longer outputs anything to elasticsearch with the same config file. The only thing it does is create the index. I've tested this with numerous index names, and without an index config so it creates a logstash index.

No documents reach elasticsearch.

Configuration: (using ElasticSearch 5.5 cluster in AWS)

input {  
mongodb {  
uri =\> 'mongo connection string'

#temp database info for the input plugin. The dir has to exist but the plugin makes the .db file.  
placeholder\_db\_dir =\> '/opt/logstash-mongodb'  
placeholder\_db\_name =\> 'logstash\_sqlite.db'

#regex list of collections to index.  
collection =\> 'collection regex'

batch\_size =\> 300  
}  
}

output {  
elasticsearch {  
hosts =\> ["aws-es-cluster-endpoint"]  
index =\> "test"

#flush\_size =\> 50

#commented out for troubleshooting.  
#document\_id =\> "%{[mongo\_id]}"

#document\_type =\> "%{[\_class]}"  
}

stdout { codec =\> rubydebug { metadata =\> true } }  
}

What I've done:

- Verified output comes in through the rubydebug stdout - tons of it.
- DEBUG logs come from mongo, but not from the elasticsearch plugin
- re-installed the es output plugin, and even upgraded it.
- rebooted the machine
- run the logstash config test utility and it says my config is fine.
- I know it can talk to ES because the index is being created.
- commented out all non-essential config options

The only thing I've done is upgraded logstash and thus the es output plugin as well

Any help is appreciated.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 22, 2017, 12:49am UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/2 "2017-09-22T00:49:58Z")

</div>

> [@Jeffrey\_Blayney](#):
>
> The only thing it does is create the index.

You need to understand something fundamental about Logstash's Elasticsearch output plugin: It doesn't create indices. Ever. It does, however, send a request to Elasticsearch that is, in effect, "Please put these documents in the index named `logstash-YYYY.MM.dd`". Elasticsearch receives the request, and if the index does not exist, creates the index, and then indexes the documents into it. What this means is that if the index is created, something got sent. Whether it got indexed or not is a different story.

I'm thinking that you might have a mapping conflict, and that's why the documents aren't making it into the index. You should update your mapping template (if you're using one) to reflect the changes.

Was Logstash 2.2 indexing to Elasticsearch 5.5?

---

<div class="post-metadata">

### Author: ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)
#### Post date: [September 22, 2017, 4:41pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/3 "2017-09-22T16:41:45Z")

</div>

I understand that, my point was only that logstash is connecting to elasticsearch and something is happening, so a live connection is not the problem.

Yes logstash 2.2 was indexing to Elasticsearch 5.5 using the ES output plugin - it was an older version of the plugin though, not sure which version.

I don't see what the mapping has to do with it. I am not setting any mapping, and any mapping that gets created would be the default that gets created or applied when an index is created. I could be a little ignorant here, but how would a default mapping or nonexistent mapping cause a document to not get indexed when it was indexed just fine by the old plugin?

Also, why aren't there any ES DEBUG logs being output?

Thanks for any additional help!

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 22, 2017, 4:46pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/4 "2017-09-22T16:46:56Z")

</div>

> [@Jeffrey\_Blayney](#):
>
> I don't see what the mapping has to do with it. I am not setting any mapping, and any mapping that gets created would be the default that gets created or applied when an index is created.

Unless you disable the feature, Logstash uploads a template by default, though it will only apply to `logstash-YYYY.MM.dd` indices. The index template for Logstash 2.2 would have mapping defaults tuned to Elasticsearch 2.x. Elasticsearch 5.x has a completely different set of mappings (e.g. `fieldname.raw` changed in favor of `fieldname.keyword`). That collision could explain the problem, but it might be a red herring.

> [@Jeffrey\_Blayney](#):
>
> Also, why aren't there any ES DEBUG logs being output?

Do you only have a single node? Did you dial up the Elasticsearch log level? Have you tried running Logstash with debug logging?

---

<div class="post-metadata">

### Author: ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)
#### Post date: [September 25, 2017, 8:31pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/5 "2017-09-25T20:31:13Z")

</div>

> [@theuntergeek](#):
>
> ES

About the logstash logging: I'm running it on the commandline which throws these weird errors about not being able to find a config file in the paths that actually contain the config file. Researching this showed me that this is only because I'm running logstash on the commandline and not as a service. Logstash will default to using DEBUG logging if it cannot find the config file. I'm not sure if this means that the input or output plugins will default to the same level however. Do you know if the plugins can have a different log level set than logstash itself?

Regarding Mappings: I found that I have mappings for indexes that exist. I've been deleting the indexes that logstash creates between attempts, and apparently the mappings go along with them.

I looked at the Templates using: GET /\_template?pretty=true"

There was an old template for logstash. I deleted the template with DELETE \_template/{{template-name}},

And it still doesn't actually send data to Elasticsearch, although \*elasticsearch is still creating the index when the docs are being sent.

Any additional help appreciated!

-Jeff

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 25, 2017, 10:11pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/6 "2017-09-25T22:11:56Z")

</div>

You should turn up debug logging in both Logstash and Elasticsearch. If mappings are being created, then Elasticsearch is at least getting an index request from Logstash. The question now becomes, "what's it doing, if it's not indexing?"

---

<div class="post-metadata">

### Author: ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)
#### Post date: [September 26, 2017, 8:20pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/7 "2017-09-26T20:20:27Z")

</div>

Sorry I might be a little dense here - the central documentation for the ES output plugin doesn't seem to have any information about special debug logging. In fact the page doesn't even have the word 'debug' on the page at all. I see the option for 'failure\_type\_logging\_whitelist' and 'enable\_metric', but they both default to being more verbose already.

Thanks for any additional help.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 26, 2017, 10:12pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/8 "2017-09-26T22:12:52Z")

</div>

You'd have to set `log.level: debug` in your `logstash.yml`, and `rootLogger.level = debug` in `log4j2.properties` in your Elasticsearch configuration (`/etc/elasticsearch`, or the `config` directory wherever you installed it).

Then look in the logs afterward. I'd start with the Logstash logs first.

---

<div class="post-metadata">

### Author: ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)
#### Post date: [September 27, 2017, 6:50pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/9 "2017-09-27T18:50:17Z")

</div>

Two quick rants about logstash 5.x.

[red herring]  
I was able to fix my issues with logstash not being able to find the config files, you need to run it under the user 'logstash'. This issue that was closed could have resulted in a code change to at least give a message or warning that makes sense - "This error may be because you're not running logstash as the logstash user or as a service"

> <https://github.com/elastic/logstash/issues/6921>

[red herring]  
More very relevant complaints about the logstash 5.x documentation: [Logstash 5 not running](https://discuss.elastic.co/t/logstash-5-not-running/64449/7)

I've modified the config files as suggested.

[red herring]  
Now its complaining that it can't find a pipeline config even though I'm specifying it with a -f option... wow this is getting a tad ridiculous. I'll log a bug on the project page. For now I fixed it by putting my config in /etc/logstash/conf.d

Here is the warning I'm receiving:

{"type"=\>"mapper\_parsing\_exception", "reason"=\>"Field [\_id] is a metadata field and cannot be added inside a document. Use the index API request parameters."

At least now I'm getting some feedback from ES, although the ruby output plugin doesn't show the mongo output when I'm running logstash as the logstash user/as a service.

Thanks for your guidance! Hopefully logstash 5.x updates will add more relevant error messages and make it a little easier to use, with a consistent behavior across commandline & config options.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [September 27, 2017, 7:01pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/10 "2017-09-27T19:01:30Z")

</div>

Sorry you had a hard time. 5.x is a major version upgrade, and clearly we can do better at helping users transition.

---

<div class="post-metadata">

### Author: ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)
#### Post date: [September 27, 2017, 7:58pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/11 "2017-09-27T19:58:17Z")

</div>

Fixed with:

filter {  
mutate {  
remove\_field =\> ["\_id"]  
}  
}

---

<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: [October 25, 2017, 7:58pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-does-not-write-to-elasticsearch/101401/12 "2017-10-25T19:58:19Z")

</div>

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