Elastic Search

Elasticsearch Show Watch Information

“One of the most influential features in Elasticsearch, on top of everything else, is watchers. Watchers allow you to define a set of actions depending on various conditions evaluated based on the provided data.

For example, you can tell Elasticsearch to send an email when the cluster health changes, CPU usage is higher for a specific period of time when a specific file is accessed, and many more. To say that watchers are a revolutionary feature would be an understatement.

However, due to the scope of this tutorial, we will not explore how watchers work or how to use them.

This tutorial aims to show you how to use the Elasticsearch watcher API to gather information about an existing watcher.

You can explore the docs to learn more about Elasticsearch watchers.”

Elasticsearch Get Watcher API

The GET watcher API allows us to fetch watch information by its ID. The request syntax is as shown below:

GET _watcher/watch/<watch_id>

The request requires manage_watcher or monitor_watcher privileges for usa.e

Example

Suppose we have a watcher that uses metricbeat to monitor when a docker container is created and sends an email if true.

We can use the request below to retrieve information about the watcher as shown:

The following example shows how to use the get watche r

curl -XGET "http://localhost:9200/_watcher/watch/81614bf8-2078-4e5d-9318-6622af146649" -H "kbn-xsrf: reporting"

This should return detailed information about the watcher as shown:

In this case, we can see the watcher details, including the defined conditions and the actions taken.

Conclusion

This simple tutorial covers using the get watcher API to gather information about an existing watcher in an Elasticsearch cluster.

Thanks for reading & Happy cluster admin!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list