Skip to content

Commit

Permalink
Merge pull request #17 from NETWAYS/docs/readme-flags
Browse files Browse the repository at this point in the history
Update help texts and README
  • Loading branch information
Philipp Dorschner authored Dec 9, 2022
2 parents 39bc084 + 7fbea7f commit e5ad9e3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
/dist/
coverage.html
coverage.out
check_elasticsearch*
66 changes: 43 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ query.

## Usage

```
Usage:
check_elasticsearch [flags]
check_elasticsearch [command]
Available Commands:
health Checks the health status of an Elasticsearch cluster
query Checks the total hits/results of an Elasticsearch query
Flags:
-H, --hostname string Hostname of the Elasticsearch instance (default "localhost")
-p, --port int Port of the Elasticsearch instance (default 9200)
-U, --username string Username if authentication is required
-P, --password string Password if authentication is required
-S, --tls Use a HTTPS connection
--insecure Skip the verification of the server's TLS certificate
-t, --timeout int Timeout in seconds for the CheckPlugin (default 30)
-h, --help help for check_elasticsearch
-v, --version version for check_elasticsearch
```

### Health

Checks the health status of an Elasticsearch cluster.
Expand All @@ -13,26 +34,22 @@ Checks the health status of an Elasticsearch cluster.
Usage:
check_elasticsearch health
Flags:
-h, --help help for health
Global Flags:
-H, --hostname string Hostname or ip address of elasticsearch node (default "localhost")
--insecure Allow use of self signed certificates when using SSL
-P, --password string Password if authentication is required
-p, --port int Port of elasticsearch node (default 9200)
-S, --tls Use secure connection
-U, --username string Username if authentication is required
The cluster health status is:
green = OK
yellow = WARNING
red = CRITICAL
```

#### Elasticsearch cluster with green status (all nodes are running)
Examples:

Elasticsearch cluster with green status (all nodes are running):

```
$ check_elasticsearch health -U exampleuser -P examplepassword -S --insecure
OK - Cluster es-example-cluster is green | status=0 nodes=3 data_nodes=3 active_primary_shards=10 active_shards=20
```

#### Elasticsearch cluster with yellow status (not all nodes are running)
Elasticsearch cluster with yellow status (not all nodes are running):

```
$ check_elasticsearch health -U exampleuser -P examplepassword -S --insecure
Expand All @@ -41,31 +58,34 @@ WARNING - Cluster es-example-cluster is yellow | status=1 nodes=2 data_nodes=2 a

### Query

Checks the total hits/results of an Elasticsearch query.<br>
The plugin is currently capable to return the total hits of documents based on a provided query string.
Checks the total hits/results of an Elasticsearch query.

Hint: The plugin is currently capable to return the total hits of documents based on a provided query string.

```
Usage:
check_elasticsearch query [flags]
Flags:
-q, --query string Elasticsearch query
-I, --index string The index which will be used (default "_all")
-k, --msgkey string Message of messagekey to display
-m, --msglen int Number of characters to display in latest message (default 80)
-w, --warning uint Warning threshold for total hits (default 20)
-c, --critical uint Critical threshold for total hits (default 50)
-h, --help help for query
-q, --query string The Elasticsearch query
-I, --index string Name of the Index which will be used (default "_all")
-k, --msgkey string Message of messagekey to display
-m, --msglen int Number of characters to display in the latest message (default 80)
-w, --warning string Warning threshold for total hits (default "20")
-c, --critical string Critical threshold for total hits (default "50")
-h, --help help for query
```

#### Search for total hits without any message
Examples:

Search for total hits without any message:

```
$ check_elasticsearch query -q "event.dataset:sample_web_logs and @timestamp:[now-5m TO now]" -I "kibana_sample_data_logs"
CRITICAL - Total hits: 14074 | total=14074;20;50
```

#### Search for total hits with message
Search for total hits with message:

```
$ check_elasticsearch query -q "event.dataset:sample_web_logs and @timestamp:[now-5m TO now]" -I "kibana_sample_data_logs" -k "message"
Expand Down
6 changes: 3 additions & 3 deletions cmd/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ var healthCmd = &cobra.Command{
Long: `Checks the health status of an Elasticsearch cluster
The cluster health status is:
green = OK
yellow = WARNING
red = CRITICAL.`,
green = OK
yellow = WARNING
red = CRITICAL`,
Example: " check_elasticsearch health --hostname \"127.0.0.1\" --port 9200 --username \"exampleUser\" " +
"--password \"examplePass\" --tls --insecure",
Run: func(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ func init() {

fs := queryCmd.Flags()
fs.StringVarP(&cliQueryConfig.Query, "query", "q", "",
"Elasticsearch query")
"The Elasticsearch query")
fs.StringVarP(&cliQueryConfig.Index, "index", "I", "_all",
"The index which will be used ")
"Name of the Index which will be used")
fs.StringVarP(&cliQueryConfig.MessageKey, "msgkey", "k", "",
"Message of messagekey to display")
fs.IntVarP(&cliQueryConfig.MessageLen, "msglen", "m", 80,
"Number of characters to display in latest message")
"Number of characters to display in the latest message")
fs.StringVarP(&cliQueryConfig.Warning, "warning", "w", "20",
"Warning threshold for total hits")
fs.StringVarP(&cliQueryConfig.Critical, "critical", "c", "50",
Expand Down
10 changes: 5 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ func init() {

pfs := rootCmd.PersistentFlags()
pfs.StringVarP(&cliConfig.Hostname, "hostname", "H", "localhost",
"Address of elasticsearch node")
"Hostname of the Elasticsearch instance")
pfs.IntVarP(&cliConfig.Port, "port", "p", 9200,
"Port of elasticsearch node")
"Port of the Elasticsearch instance")
pfs.StringVarP(&cliConfig.Username, "username", "U", "",
"Username if authentication is required")
pfs.StringVarP(&cliConfig.Password, "password", "P", "",
"Password if authentication is required")
pfs.BoolVarP(&cliConfig.TLS, "tls", "S", false,
"Use secure connection")
"Use a HTTPS connection")
pfs.BoolVar(&cliConfig.Insecure, "insecure", false,
"Allow use of self signed certificates when using SSL")
"Skip the verification of the server's TLS certificate")
pfs.IntVarP(&Timeout, "timeout", "t", Timeout,
"Timeout for the check")
"Timeout in seconds for the CheckPlugin")

rootCmd.Flags().SortFlags = false
pfs.SortFlags = false
Expand Down

0 comments on commit e5ad9e3

Please sign in to comment.