# Stop Logstash automatically if Elasticsearch is not running

**URL:** <https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499>\
**Category:** Logstash\
**Created:** [June 6, 2019, 6:18am UTC](https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499 "2019-06-06T06:18:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Velmurugan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/velmurugan/32/47313_2.png) [@Velmurugan](https://discuss.elastic.co/u/Velmurugan)\
**Post date:** [June 6, 2019, 6:18am UTC](https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499/1 "2019-06-06T06:18:55Z")

</div>

I am running **logstash** on **server 1** and I have configured **Elasticsearch** and kibana on **server 2** resulting that server 1's logstash will send data/logs to server 2's Elasticsearch.

Recently I have encountered one problem regarding this setup which was when Elasticsearch on server 2 is down but server 1's logstash tries to send logs to that and keep on spawning threads which result in high CPU utilization.

I am looking for the solution in which if Elasticseach is down, Logstash should not send any data to that Elasticsearch. I'm not using ES cluster.

---

<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:** [June 6, 2019, 10:57pm UTC](https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499/2 "2019-06-06T22:57:15Z")

</div>

There's nothing native to the stack, you'd need to figure it out yourself sorry to say.

---

<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 7, 2019, 12:07am UTC](https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499/3 "2019-06-07T00:07:39Z")

</div>

I would not expect to see high CPU in those circumstances. If the elasticsearch output cannot open a connection to the ES instance it should retry, the internal queues should fill, and back-pressure should stop the inputs processing. I would expect the elasticsearch instance to need maybe 2% of a CPU to try to resurrect the connection.

What makes you think that logstash is spawning additional threads? Have you used the [hot threads](https://www.elastic.co/guide/en/logstash/current/hot-threads-api.html) API to monitor what it is doing?

---

<div class="post-metadata">

**Author:** ![Velmurugan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/velmurugan/32/47313_2.png) [@Velmurugan](https://discuss.elastic.co/u/Velmurugan)\
**Post date:** [June 7, 2019, 4:09am UTC](https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499/4 "2019-06-07T04:09:47Z")

</div>

Thanks for the response. Will try hot threads API.

---

<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 5, 2019, 4:09am UTC](https://discuss.elastic.co/t/stop-logstash-automatically-if-elasticsearch-is-not-running/184499/5 "2019-07-05T04:09:53Z")

</div>

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