1- {{- /* Ignore this text, until templating is ran via [ sensu-plugin-tool] ( https://github.com/sensu/sensu-plugin-tool ) the below badge links wiill not render * / -}}
1+ # Sensu Elasticsearch Check
2+ ## Overview
3+ check-es-cluster-health is a Sensu check plugin built using the [ Sensu Plugin SDK] [ 2 ] to monitor Elasticsearch cluster health, node status, and file descriptor usage. This plugin provides comprehensive monitoring capabilities for Elasticsearch clusters through Sensu's monitoring pipeline.
24
3- [ ![ Sensu Bonsai Asset] ( https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu )] (https://bonsai.sensu.io/assets/{{ .GithubUser }}/{{ .GithubProject }})
4- ![ Go Test] (https://github.com/{{ .GithubUser }}/{{ .GithubProject }}/workflows/Go%20Test/badge.svg)
5- ![ goreleaser] (https://github.com/{{ .GithubUser }}/{{ .GithubProject }}/workflows/goreleaser/badge.svg)
65
7- # Check Plugin Template
86
9- ## Overview
10- check-plugin-template is a template repository which wraps the [ Sensu Plugin SDK] [ 2 ] .
11- To use this project as a template, click the "Use this template" button from the main project page.
12- Once the repository is created from this template, you can use the [ Sensu Plugin Tool] [ 9 ] to
13- populate the templated fields with the proper values.
7+ ## Table of Contents
8+ - [ Configuration] ( #configuration )
9+ - [ Command-line Arguments] ( #Command-line-arguments )
10+ - [ Environment Variables] ( #environment-variables )
11+ - [ Sensu Check Definition] ( #sensu-check-definition )
12+ - [ Examples] ( #examples )
13+ - [ Output Examples] ( #output-examples )
14+ - [ Exit Codes] ( #exit-codes )
1415
15- ## Functionality
16+ ## Configuration
1617
17- After successfully creating a project from this template, update the ` Config ` struct with any
18- configuration options for the plugin, map those values as plugin options in the variable ` options ` ,
19- and customize the ` checkArgs ` and ` executeCheck ` functions in [ main.go] [ 7 ] .
18+ ### Command-line-arguments
19+
20+ | Argument | Shorthand | Default | Description |
21+ | ------------------------| -----------| -----------| -------------------------------------------------|
22+ | --host | -H | localhost | Elasticsearch host |
23+ | --port | -p | 9200 | Elasticsearch port |
24+ | --scheme | -s | http | Elasticsearch connection scheme (http/https) |
25+ | --user | -u | | Elasticsearch connection user |
26+ | --password | -P | | Elasticsearch connection password |
27+ | --timeout | -t | 30 | Elasticsearch query timeout in seconds |
28+ | --status-timeout | -T | 0 | Time to wait for cluster status to be green (s) |
29+ | --level | -l | | Level of detail (cluster, indices, shards) |
30+ | --local | -L | false | Return local information only |
31+ | --index | -i | | Comma-separated list of indices to check |
32+ | --alert-status | -a | | Only alert for specific status (RED/YELLOW/GREEN)|
33+ | --master-only | -m | false | Only run on master node |
34+ | --check-fd | -f | false | Check file descriptor usage |
35+ | --fd-critical | -c | 90 | Critical percentage of FD usage |
36+ | --fd-warning | -w | 80 | Warning percentage of FD usage |
37+ | --cert-file | -C | | Cert file to use |
38+ | --insecure-skip-verify | -k | false | Skip SSL certificate verification |
39+ | --check-nodes | -n | | Check node status (local/all) |
40+
41+ ### Environment Variables
42+
43+ All parameters can also be set via environment variables prefixed with ` CHECK_ES_ ` :
44+
45+ | Argument | Environment Variable |
46+ | ------------------------| -------------------------------|
47+ | --host | CHECK_ES_HOST |
48+ | --port | CHECK_ES_PORT |
49+ | --scheme | CHECK_ES_SCHEME |
50+ | --user | CHECK_ES_USER |
51+ | --password | CHECK_ES_PASSWORD |
52+ | --timeout | CHECK_ES_TIMEOUT |
53+ | --status-timeout | CHECK_ES_STATUS_TIMEOUT |
54+ | --level | CHECK_ES_LEVEL |
55+ | --local | CHECK_ES_LOCAL |
56+ | --index | CHECK_ES_INDEX |
57+ | --alert-status | CHECK_ES_ALERT_STATUS |
58+ | --master-only | CHECK_ES_MASTER_ONLY |
59+ | --check-fd | CHECK_ES_FD |
60+ | --fd-critical | CHECK_ES_FD_CRITICAL |
61+ | --fd-warning | CHECK_ES_FD_WARNING |
62+ | --cert-file | CHECK_ES_CERT_FILE |
63+ | --insecure-skip-verify | CHECK_ES_INSECURE_SKIP_VERIFY |
64+ | --check-nodes | CHECK_ES_NODES |
65+
66+
67+ ## Sensu Check Definition
68+ ```
69+ ---
70+ type: CheckConfig
71+ api_version: core/v2
72+ metadata:
73+ name: check-es-cluster-health
74+ namespace: default
75+ spec:
76+ command: >-
77+ check-es-cluster-health
78+ --host elasticsearch.example.com
79+ --port 9200
80+ --scheme https
81+ --user admin
82+ --password secret
83+ --check-fd
84+ --fd-warning 80
85+ --fd-critical 90
86+ subscriptions:
87+ - elasticsearch
88+ interval: 60
89+ publish: true
90+ runtime_assets:
91+ - sensu-check-es-cluster-health
92+ timeout: 30
93+ handlers:
94+ - email
95+ - slack
96+ ```
2097
21- When writing or updating a plugin's README from this template, review the Sensu Community
22- [ plugin README style guide] [ 3 ] for content suggestions and guidance. Remove everything
23- prior to ` # {{ .Name }} ` from the generated README file, and add additional context about the
24- plugin per the style guide.
2598
26- ## Releases with Github Actions
99+ ## Examples
27100
28- To release a version of your project, simply tag the target sha with a semver release without a ` v `
29- prefix (ex. ` 1.0.0 ` ). This will trigger the [ GitHub action] [ 5 ] workflow to [ build and release] [ 4 ]
30- the plugin with goreleaser. Register the asset with [ Bonsai] [ 8 ] to share it with the community!
101+ ### Basic cluster health check
31102
32- ***
103+ `./check-es-cluster-health --host elasticsearch.example.com --port 9200
104+ `
33105
34- # {{ .Name }}
106+ ### Cluster health with authentication
35107
36- ## Table of Contents
37- - [ Overview] ( #overview )
38- - [ Files] ( #files )
39- - [ Usage examples] ( #usage-examples )
40- - [ Configuration] ( #configuration )
41- - [ Asset registration] ( #asset-registration )
42- - [ Check definition] ( #check-definition )
43- - [ Installation from source] ( #installation-from-source )
44- - [ Additional notes] ( #additional-notes )
45- - [ Contributing] ( #contributing )
108+ `./check-es-cluster-health --host elasticsearch.example.com --port 9200 --user admin --password secret --scheme https
109+ `
46110
47- ## Overview
111+ ### Check file descriptors with custom thresholds
48112
49- The {{ .Name }} is a [ Sensu Check] [ 6 ] that ...
113+ `./check-es-cluster-health --check-fd --fd-warning 70 --fd-critical 90
114+ `
50115
51- ## Files
116+ ### Only alert on RED status
52117
53- ## Usage examples
118+ `./check-es-cluster-health --alert-status RED
119+ `
54120
55- ## Configuration
121+ ### Check all nodes status
56122
57- ### Asset registration
123+ `./check-es-cluster-health --check-nodes all
124+ `
58125
59- [ Sensu Assets] [ 10 ] are the best way to make use of this plugin. If you're not using an asset, please
60- consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or later, you can use the
61- following command to add the asset:
126+ ## Output Examples
62127
63- ```
64- sensuctl asset add {{ .GithubUser }}/{{ .GithubProject }}
65- ```
128+ ### Healthy cluster
129+ ` - OK: Cluster status is green `
130+ ### Warning status
131+ ` - WARNING: Cluster status is yellow `
132+ ### Critical status
133+ ` - CRITICAL: Cluster status is red `
134+ ### File descriptor warning
135+ ` - WARNING: fd usage 85.0% exceeds 80% (8500/10000) `
66136
67- If you're using an earlier version of sensuctl, you can find the asset on the [ Bonsai Asset Index ] [ https://bonsai.sensu.io/assets/{{ .GithubUser }}/{{ .GithubProject }} ] .
137+ ## Exit Codes
68138
69- ### Check definition
139+ | Code | Status | Description |
140+ | -------| ----------| ---------------------------------------------------|
141+ | 0 | OK | Cluster is healthy |
142+ | 1 | Warning | Cluster is in warning state (yellow) |
143+ | 2 | Critical | Cluster is in critical state (red) or other issue |
144+ | 3 | Unknown | Unable to determine cluster status |
145+
146+ ## Usage examples
147+ ```
148+ Sensu check for Elasticsearch cluster health and file descriptors
149+
150+ Usage:
151+ check-es-cluster-health [flags]
152+ check-es-cluster-health [command]
153+
154+ Available Commands:
155+ completion Generate the autocompletion script for the specified shell
156+ help Help about any command
157+ version Print the version number of this plugin
158+
159+ Flags:
160+ -a, --alert-status string Only alert when status matches given RED/YELLOW/GREEN or if blank all statuses
161+ -C, --cert-file string Cert file to use
162+ -f, --check-fd Check file descriptor usage
163+ -n, --check-nodes string Check node status
164+ -c, --fd-critical int Critical percentage of FD usage (default 90)
165+ -w, --fd-warning int Warning percentage of FD usage (default 80)
166+ -h, --help help for check-es-cluster-health
167+ -H, --host string Elasticsearch host (default "localhost")
168+ -i, --index string Comma separated list of indices to check health for
169+ -k, --insecure-skip-verify Skip SSL certificate verification
170+ -l, --level string Level of detail to check returned information (cluster, indices, shards)
171+ -L, --local Return local information, do not retrieve the state from master node
172+ -m, --master-only Use master Elasticsearch server only
173+ -P, --password string Elasticsearch connection password
174+ -p, --port int Elasticsearch port (default 9200)
175+ -s, --scheme string Elasticsearch connection scheme (http/https) (default "http")
176+ -T, --status-timeout int Time to wait for cluster status to be green in seconds
177+ -t, --timeout int Elasticsearch query timeout in seconds (default 30)
178+ -u, --user string Elasticsearch connection user
179+
180+ Use "check-es-cluster-health [command] --help" for more information about a command.
70181
71- ``` yml
72- ---
73- type : CheckConfig
74- api_version : core/v2
75- metadata :
76- name : {{ .GithubProject }}
77- namespace : default
78- spec :
79- command : {{ .GithubProject }} --example example_arg
80- subscriptions :
81- - system
82- runtime_assets :
83- - {{ .GithubUser }}/{{ .GithubProject }}
84182```
85183
86184## Installation from source
@@ -89,7 +187,7 @@ The preferred way of installing and deploying this plugin is to use it as an Ass
89187like to compile and install the plugin from source or contribute to it, download the latest version
90188or create an executable script from this source.
91189
92- From the local path of the {{ .GithubProject }} repository:
190+ From the local path of the ` sensu-elasticsearch-check ` repository:
93191
94192```
95193go build
@@ -104,10 +202,7 @@ For more information about contributing to this plugin, see [Contributing][1].
104202[ 1 ] : https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md
105203[ 2 ] : https://github.com/sensu/sensu-plugin-sdk
106204[ 3 ] : https://github.com/sensu-plugins/community/blob/master/PLUGIN_STYLEGUIDE.md
107- [ 4] : https://github.com/{{ .GithubUser }}/{{ .GithubProject }}/blob/master/.github/workflows/release.yml
108- [ 5] : https://github.com/{{ .GithubUser }}/{{ .GithubProject }}/actions
109- [ 6 ] : https://docs.sensu.io/sensu-go/latest/reference/checks/
110- [ 7 ] : https://github.com/sensu/check-plugin-template/blob/master/main.go
111- [ 8 ] : https://bonsai.sensu.io/
112- [ 9 ] : https://github.com/sensu/sensu-plugin-tool
113- [ 10 ] : https://docs.sensu.io/sensu-go/latest/reference/assets/
205+ [ 4 ] : https://docs.sensu.io/sensu-go/latest/reference/checks/
206+ [ 5 ] : https://github.com/sensu/check-plugin-template/blob/master/main.go
207+ [ 6 ] : https://bonsai.sensu.io/
208+ [ 7 ] : https://github.com/sensu/sensu-plugin-tool
0 commit comments