# Automating ELK Health Check

## Introduction

While I am not a programmer, in cybersecurity, scripting has always been a must skill to upgrade my skillset, and GoLang is gaining popularity specially among cybersecurity professionals for reasons I won't be talking about in this blog post. So, as a start, I tried to answer my needs in troubleshooting an Elasticsearch clusters and automate some of the frequent checks using GoLang since Elastic Stack is my favorite set of tools for threat hunting.

**GitHub project repository:** <https://github.com/H1L021/ELK_Health_Check>

## ELK Health Check

![Running ELK Health Check](https://1286158324-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO79pt4NiZPFhlGCglR%2F-MWLfzvC9D0yeDPBmpwK%2F-MWLlh7bTHIbM_m283AA%2Fimage.png?alt=media\&token=cdef1e9f-a88c-408c-82b9-97e84a7b2991)

This is a script that runs multiple basic checks for an Elasticsearch cluster health and saves everything to text files. The script runs the following checks:

1. **Unavailable nodes based on the number of nodes you provide in your cluster.**
2. **Checks indices status (Green, Yellow, Red). Warns you if it detects Yellow indices or Red ones.**
3. **Verifies cluster's health using `_cluster/health` API call.**
4. **Checks allocation status using `_cat/allocation` API call**
5. **Looks and warns you for unassigned shards;**
6. **Creates a folder in current path and saves every output to files for later usage.**

{% hint style="warning" %}
This script only supports cluster nodes using TLS for the moment.
{% endhint %}
