2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2017-03-28 17:23:01 -04:00
|
|
|
[[api-java-stats]]
|
|
|
|
=== Stats API
|
|
|
|
|
|
|
|
The `stats` API returns the current {watcher} metrics. You can control what
|
|
|
|
metrics this API returns using the `metric` parameter.
|
|
|
|
|
|
|
|
The following example queries the `stats` API :
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
WatcherStatsResponse watcherStatsResponse = watcherClient.prepareWatcherStats().get();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
A successful call returns a response structure that can be accessed as shown:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
WatcherBuild build = watcherStatsResponse.getBuild();
|
|
|
|
|
|
|
|
// The current size of the watcher execution queue
|
|
|
|
long executionQueueSize = watcherStatsResponse.getThreadPoolQueueSize();
|
|
|
|
|
|
|
|
// The maximum size the watch execution queue has grown to
|
|
|
|
long executionQueueMaxSize = watcherStatsResponse.getThreadPoolQueueSize();
|
|
|
|
|
|
|
|
// The total number of watches registered in the system
|
|
|
|
long totalNumberOfWatches = watcherStatsResponse.getWatchesCount();
|
|
|
|
|
|
|
|
// {watcher} state (STARTING,STOPPED or STARTED)
|
|
|
|
WatcherState watcherState = watcherStatsResponse.getWatcherState();
|
|
|
|
--------------------------------------------------
|