
The logstash-indexer services sometimes fall out of the elasticsearch cluster when it is under heavy load and unable to respond to pings. Logstash doesn't do anything to reconnect :( so restart the service if a node detects that it has fallen out of the cluster. Upstream bug submitted at https://logstash.jira.com/browse/LOGSTASH-1951 Change-Id: I2e7767c5fe20cff279366fec2ddadd7710dbb4a9
18 lines
454 B
Bash
18 lines
454 B
Bash
#!/bin/bash
|
|
#
|
|
# This is a work around for https://logstash.jira.com/browse/LOGSTASH-1951
|
|
# Logstash disconnects from the cluster and will not rejoin under
|
|
# its own power.
|
|
|
|
ES_ADDRESS=$1
|
|
|
|
JSON_OUT=$(curl -sf "http://${ES_ADDRESS}:9200/_cluster/nodes/${HOSTNAME}")
|
|
CURL_RET=$?
|
|
RESULT=$(echo $JSON_OUT | jq '.nodes == {}')
|
|
|
|
if [ "$CURL_RET" == "0" ] && [ "$RESULT" == "true" ] ;
|
|
then
|
|
stop --quiet logstash-indexer
|
|
start --quiet logstash-indexer
|
|
fi
|