elasticsearchHow do I set up an Elasticsearch watcher?
Setting up an Elasticsearch watcher is a 3-step process:
- Create a watch: A watch is a JSON document that defines the conditions that must be met for the watch to be triggered. For example:
PUT _watcher/watch/my_watch
{
"trigger" : {
"schedule" : {
"interval" : "10m"
}
},
"input" : {
"search" : {
"request" : {
"indices" : [
"my_index"
],
"body" : {
"query" : {
"match_all" : {}
}
}
}
}
},
"actions" : {
"log_something" : {
"logging" : {
"text" : "{{ctx.payload}}"
}
}
}
}
- Activate the watch:
PUT _watcher/watch/my_watch/_activate
- Check the watch's status:
GET _watcher/watch/my_watch
The output should look something like this:
{
"my_watch" : {
"metadata" : {
"xpack" : {
"version" : 1
},
"modified_date" : "2020-07-13T13:25:19.639Z",
"created_date" : "2020-07-13T13:25:19.639Z",
"version" : 1,
"type" : "json",
"status" : {
"state" : "active"
}
},
"watch" : {
"trigger" : {
"schedule" : {
"interval" : "10m"
}
},
"input" : {
"search" : {
"request" : {
"indices" : [
"my_index"
],
"body" : {
"query" : {
"match_all" : {}
}
}
}
}
},
"actions" : {
"log_something" : {
"logging" : {
"text" : "{{ctx.payload}}"
}
}
}
}
}
}
For more information, see the Elasticsearch Watcher documentation.
More of Elasticsearch
- How can I use Elasticsearch and ZFS together?
- How can I use Yandex Mirror to access Elasticsearch data?
- How do I use Elasticsearch with ZGC?
- How can I store and query zoned datetime values in Elasticsearch?
- How do I set up an Elasticsearch Yum repository?
- How do I configure elasticsearch to use an XMS memory allocator?
- How can I use YouTube to learn about Elasticsearch?
- How can I use Elasticsearch and Zookeeper together to manage distributed applications?
- How can I use Elasticsearch with Zammad?
- How can I use elasticsearch zone awareness to improve my software development?
See more codes...