Skip to content

Commit

Permalink
Watcher: fix metric stats names (#34951)
Browse files Browse the repository at this point in the history
The current watcher stats metric names doesn't match the current
documentation. This commit fixes the behavior of `queued_watches`
metric, deprecates `pending_watches` metric and adds `current_watches`
to match the documented behavior. It also fixes the documentation, which
introduced `executing_watches` metric that was never added.

Fixes #34865
  • Loading branch information
imotov committed Nov 1, 2018
1 parent e8fa1dc commit 11567c7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
6 changes: 3 additions & 3 deletions x-pack/docs/en/rest-api/watcher/stats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ currently being executed by {watcher}. Additional information is shared per
watch that is currently executing. This information includes the `watch_id`,
the time its execution started and its current execution phase.

To include this metric, the `metric` option should be set to `pending_watches`
To include this metric, the `metric` option should be set to `current_watches`
or `_all`. In addition you can also specify the `emit_stacktraces=true`
parameter, which adds stack traces for each watch that is being executed. These
stack traces can give you more insight into an execution of a watch.
Expand All @@ -51,7 +51,7 @@ To include this metric, the `metric` option should include `queued_watches` or

`metric`::
(enum) Defines which additional metrics are included in the response.
`pending_watches`::: Includes the current executing watches in the response.
`current_watches`::: Includes the current executing watches in the response.
`queued_watches`::: Includes the watches queued for execution in the response.
`_all`::: Includes all metrics in the response.

Expand Down Expand Up @@ -98,7 +98,7 @@ and will include the basic metrics and metrics about the current executing watch

[source,js]
--------------------------------------------------
GET _xpack/watcher/stats?metric=pending_watches
GET _xpack/watcher/stats?metric=current_watches
--------------------------------------------------
// CONSOLE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"parts": {
"metric": {
"type" : "enum",
"options" : ["_all", "queued_watches", "pending_watches"],
"options" : ["_all", "queued_watches", "current_watches", "pending_watches"],
"description" : "Controls what additional stat metrics should be include in the response"
}
},
"params": {
"metric": {
"type" : "enum",
"options" : ["_all", "queued_watches", "pending_watches"],
"options" : ["_all", "queued_watches", "current_watches", "pending_watches"],
"description" : "Controls what additional stat metrics should be include in the response"
},
"emit_stacktraces": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,55 @@
emit_stacktraces: "true"
- match: { "manually_stopped": false }
- match: { "stats.0.watcher_state": "started" }

---
"Test watcher stats current watches":
- skip:
version: " - 6.5.99"
reason: metrics were fixed in 6.6.0

- do:
xpack.watcher.stats:
metric: "current_watches"

- is_false: stats.0.queued_watches
- is_true: stats.0.current_watches

---
"Test watcher stats queued watches":
- skip:
version: " - 6.5.99"
reason: metrics were fixed in 6.6.0

- do:
xpack.watcher.stats:
metric: "queued_watches"

- is_false: stats.0.current_watches
- is_true: stats.0.queued_watches

---
"Test watcher stats queued watches using pending_watches":
- skip:
version: " - 6.5.99"
reason: metrics were fixed in 6.6.0
features: warnings

- do:
warnings:
- 'The pending_watches parameter is deprecated, use queued_watches instead'

xpack.watcher.stats:
metric: "pending_watches"

- is_false: stats.0.current_watches
- is_true: stats.0.queued_watches

---
"Test watcher stats all watches":
- do:
xpack.watcher.stats:
metric: "_all"

- is_true: stats.0.current_watches
- is_true: stats.0.queued_watches
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ protected RestChannelConsumer doPrepareRequest(final RestRequest restRequest, Wa
request.includeCurrentWatches(true);
request.includeQueuedWatches(true);
} else {
request.includeCurrentWatches(metrics.contains("queued_watches"));
request.includeQueuedWatches(metrics.contains("pending_watches"));
request.includeCurrentWatches(metrics.contains("current_watches"));
request.includeQueuedWatches(metrics.contains("queued_watches") || metrics.contains("pending_watches"));
}

if (metrics.contains("pending_watches")) {
deprecationLogger.deprecated("The pending_watches parameter is deprecated, use queued_watches instead");
}


Expand Down

0 comments on commit 11567c7

Please sign in to comment.