I am planning to get the total watchers count created in the elasticsearch cluster that is running on elkversion 8.x.x,
I tried to hit the below Watchers stats API, and it is giving me the below response
Watcher stats endpoint
https://elk_endpoint/_watcher/stats
Response
{
"_nodes": {
"total": 3,
"successful": 3,
"failed": 0
},
"cluster_name": "elk_cluster",
"manually_stopped": false,
"stats": [
{
"node_id": "yBj29GluSn2kX8FIm5myFQ",
"watcher_state": "started",
"watch_count": 0,
"execution_thread_pool": {
"queue_size": 0,
"max_size": 50
}
},
{
"node_id": "wUBFDu21Tb6nZETG7C4jsA",
"watcher_state": "started",
"watch_count": 0,
"execution_thread_pool": {
"queue_size": 0,
"max_size": 50
}
},
{
"node_id": "riLkqmfQTU2fbfzsmqxzDw",
"watcher_state": "started",
"watch_count": 67,
"execution_thread_pool": {
"queue_size": 0,
"max_size": 50
}
}
]
}
But when i hit the list watchers API, watchers count is showing as way more than above.
To get the total watchers count, I am summing up the watchers count for all the nodes in Watcher stats API.
I am showing the watchers on UI in a table where I am referring to the count returned by Watcher stats API, but I need all the watchers that exists on the index.
Please help me if there is some way if I can get the total count of all watchers irrespective of their state?
Note: In the UI table, rows count is 117 which is the total count of all the watchers returned by List Watch API, but as watcher stats count is showing only 69 (68 1), Table is only showing 69 records.
Process
We have a LIST pojo which has schema returned by List Watch API
{
"count":117,
"watches": {
....
}
}
This count is send as a modal object to show in the UI for the table, but for only 69 records, we are getting the details (iterating the rows based on the watchers stats count), rest rows are empty.
CodePudding user response:
Tldr;
How about the search api for watches ?
GET /_watcher/_query/watches
{
"count": <total number of watches>,
.
.
.
}