Skip to content

lets-qa/es_diagnostics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Elasticsearch Diagnostics Script

Overview

This script collects and logs performance metrics from an Elasticsearch cluster.

Features:

  • Supports Basic Auth, Bearer Token, or No Auth
  • Select specific diagnostics to run
  • Outputs in either pretty .log or structured .json

Usage

Basic Example

./es_diagnostics.sh --env config/dev.env

Run Specific Checks

./es_diagnostics.sh --env config/prod.env --run health,nodes,stats

Auth Support

  • ES_USER + ES_PASS → Basic Auth
  • AUTH_TOKEN → Bearer Token
  • None → No Auth

Output Modes

Set in .env:

  • MODE=pretty → Human-readable
  • MODE=json → Structured machine-friendly format

macOS Users

macOS ships with Bash 3.2 which lacks features required for JSON mode. To fix:

brew install bash

Update script shebang to:

#!/usr/local/bin/bash

Sample .env (dev.env)

ES_HOST=http://localhost:9200
ES_USER=elastic
ES_PASS=changeme
MODE=pretty

Sample .env (prod.env)

ES_HOST=https://your-prod-es.example.com
AUTH_TOKEN=your-token-here
MODE=json

Diagnostic Modes and Tags

Use the --run flag to selectively execute checks. Below is a list of available modes:

Tag Description Elasticsearch Endpoint
health Cluster health status /_cluster/health
stats Cluster-wide statistics /_cluster/stats
nodes Node-level JVM, CPU, FS stats /_nodes/stats/jvm,os,process,fs,indices
pending Cluster pending tasks /_cluster/pending_tasks
indexstats Index stats (docs, store, etc.) /_stats
shards Shard allocation details /_cat/shards?format=json
indices Index summary information /_cat/indices?format=json
catnodes Node summary (cat API) /_cat/nodes?format=json
threadpool Thread pool metrics per node /_nodes/stats/thread_pool

Example:

./es_diagnostics.sh --env config/prod.env --run health,stats,threadpool

Help:

./es_diagnostics.sh -h
Usage: ./es_diagnostics.sh [--env FILE] [--run TAG1,TAG2,...]

Options:
  --env FILE       Path to .env file with configuration variables.
  --run TAGS       Comma-separated list of diagnostic checks to run.
                   Available TAGS: health, stats, nodes, pending, indexstats, shards, indices, catnodes, threadpool
  -h, --help       Display this help message.

Examples:
  ./es_diagnostics.sh --env dev.env
  ./es_diagnostics.sh --env prod.env --run health,nodes

About

A tool for Diagnosing ES Health

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages