From d3c67fea52abe1340fa233c3696e00f9d2b54ef7 Mon Sep 17 00:00:00 2001 From: satk0 <54475808+satk0@users.noreply.github.com> Date: Wed, 13 Mar 2024 18:21:59 +0000 Subject: [PATCH] Add unsuccessful metrics to docs metrics (#313) --- docker-compose.yml | 2 +- scripts/add_metrics_to_readme.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c4842b12..5b1a7508 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: restart: unless-stopped volumes: - logstash-data:/usr/share/logstash/data - - ./.docker/logstash.conf:/usr/share/logstash/pipeline/logstash.conf:ro + - ./.docker/logstash.conf:/usr/share/logstash/pipeline/logstash.conf - ./.docker/logstash.yml:/usr/share/logstash/config/logstash.yml:ro depends_on: - elasticsearch diff --git a/scripts/add_metrics_to_readme.sh b/scripts/add_metrics_to_readme.sh index 30eeb60d..54b7c9e4 100755 --- a/scripts/add_metrics_to_readme.sh +++ b/scripts/add_metrics_to_readme.sh @@ -9,6 +9,32 @@ function getMetrics() { done } +function failureConfigChange() { + local logstashCID + logstashCID=$( docker ps -a | grep 'logstash-exporter-logstash-1' | awk '{print $1}' ) + local logstashConf + logstashConf='/usr/share/logstash/pipeline/logstash.conf' + # "logstash pid should be always 1 AFAIK" ~ Kuskoman, 2024 + local logstashPID + logstashPID=1 + + docker exec -it "$logstashCID" sh -c "echo 'Wrong Config' >> $logstashConf" + + # reload logstash + docker exec -it "$logstashCID" sh -c "kill -1 $logstashPID" + + # bring back previous config + # walk around with 'cp' to avoid replacing config inside container + docker exec "$logstashCID" sh -c "sed '\$d' $logstashConf > /tmp/prev_logstash.conf" + docker exec "$logstashCID" sh -c "cp /tmp/prev_logstash.conf $logstashConf" + + # reload logstash + docker exec -it "$logstashCID" sh -c "kill -1 $logstashPID" + +} + +failureConfigChange + FILE=README.md while IFS= read -r line; do LINES+=("$line"); done < $FILE