Elasticblink: Elasticsearch x Blinkstick

Elasticblink is a basic Python application which monitors the health status of an Elasticsearch (ES) cluster and outputs the health as a color on a Blinkstick USB LED. This application operates with Elasticsearch 7.x clusters, but the code could be forked to handle other Elasticsearch versions.

Github Repo: https://github.com/kasp0r/elasticblink

Execution of the application – it does a test of RGB and then connects to the configured Elasticsearch cluster.


To the use the application you’ll require:

Setup and Configuration

You’ll need Python 3. This setup assumes the existence of PIP. The requirements.txt file contains pacakages for installation.

pip install -r requirements.txt

A base configuration file can be found in the root directory (config.json). This file handles credentials and parameters for connection to the Elasticsearch cluster as well as color configurations for Elasticblink.

Example configuration:

  "elastic_credentials": {
    "protocol": "http",
    "host": "",
    "port": 9200,
    "user": "changeme",
    "pass": "changeme"
  "cluster_name": "elastic_cluster",
  "poll_period_seconds": 60,
  "status_color": {
    "green": [0, 0, 255],
    "yellow": [255, 255, 0],
    "red" : [255, 0, 0]

The elasic_credentials section of the configuration is required and used for specifying the Elasticsearch host and user credentials. The protocol can be specified as http or https. In this example we’ve used the IP address to reference the master ES node, but another hostname can easily be provided. Default port and user and pass details are also supplied.

The cluster_name references the cluster which will be monitored from the cat/health endpoint. This is configured in the Elasticsearch configuration YAMLs. It can also be found by visiting the _cat/health endpoint.

poll_period_seconds specifies how often the cluster will be polled for its status. By default this is set to 60 seconds.

The status_color dictionary is read raw for referencing status. Elasticsearch typically uses three colors to define status (green, yellow and red). Each status is associated with a list of integers representing Red-Green-Blue values with a minimum of 0 and a maximum of 255. The configuration allows one to use or modify these statuses. You can for instance make the green status another color (non-green) by modifying the RGB array value. In such case that the Blinkstick cannot communicate with the Elasticsearch cluster, then it will show a holding white LED light. A message about an issue determining the cluster will be produced in the log.


Once configuration has been set the usage of the script is fairly straightforward with the --help flag showing help on usage:

> python elasticblink.py --help 
usage: elasticblink.py [-h] --config CONFIG [--initialisation_test {yes,no}]

Version 1.0. Simple script to monitor an ElasticSearch cluster or node status
and produce a status on a Blinkstick.

  -h, --help            show this help message and exit
  --config CONFIG, -k CONFIG
                        Configuration file to read parameters and
                        configurations from (default: config.json)
  --initialisation_test {yes,no}, -t {yes,no}
                        Turn off or on the initialisation test executed before
                        monitoring. This test will check both the Blinkstick
                        and the Elasticsearch connection.

Process finished with exit code 0

Example execution. The Blinkstick should shine the status of the Elasticsearch cluster.

# Example usage of configuration config.json
> python elasticblink.py -k=config.json 
2022-12-19 12:52:27,588 [INFO] Arguments: Namespace(config='config.json', initialisation_test='yes')
2022-12-19 12:52:27,588 [INFO] Configuration JSON read from: /mnt/elasticblink/config.json
2022-12-19 12:52:29,207 [INFO] Blinkstick: BS044665-3.0 turned off
2022-12-19 12:52:29,213 [INFO] GET [status:200 request:0.006s]
2022-12-19 12:52:29,215 [INFO] HEAD [status:200 request:0.001s]
2022-12-19 12:52:29,215 [INFO] Elasticsearch Connection Ping Test SUCCESS!
2022-12-19 12:52:30,253 [INFO] GET [status:200 request:0.004s]
2022-12-19 12:52:30,255 [INFO] GET [status:200 request:0.002s]

When first executed the script performs, by default, a test where it rotates the colors of the Blinkstick between red, green and blue to check if requests are working.

Release Notes

  • v1.0 Provision of base script connects to Elasticsearch 7.x clusters and works with Blinkstick Nano.