Skip to content

Commit 11567c7

Browse files
committed
Watcher: fix metric stats names (#34951)
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
1 parent e8fa1dc commit 11567c7

File tree

4 files changed

+63
-7
lines changed

4 files changed

+63
-7
lines changed

x-pack/docs/en/rest-api/watcher/stats.asciidoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ currently being executed by {watcher}. Additional information is shared per
2525
watch that is currently executing. This information includes the `watch_id`,
2626
the time its execution started and its current execution phase.
2727

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

5252
`metric`::
5353
(enum) Defines which additional metrics are included in the response.
54-
`pending_watches`::: Includes the current executing watches in the response.
54+
`current_watches`::: Includes the current executing watches in the response.
5555
`queued_watches`::: Includes the watches queued for execution in the response.
5656
`_all`::: Includes all metrics in the response.
5757

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

9999
[source,js]
100100
--------------------------------------------------
101-
GET _xpack/watcher/stats?metric=pending_watches
101+
GET _xpack/watcher/stats?metric=current_watches
102102
--------------------------------------------------
103103
// CONSOLE
104104

x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"parts": {
99
"metric": {
1010
"type" : "enum",
11-
"options" : ["_all", "queued_watches", "pending_watches"],
11+
"options" : ["_all", "queued_watches", "current_watches", "pending_watches"],
1212
"description" : "Controls what additional stat metrics should be include in the response"
1313
}
1414
},
1515
"params": {
1616
"metric": {
1717
"type" : "enum",
18-
"options" : ["_all", "queued_watches", "pending_watches"],
18+
"options" : ["_all", "queued_watches", "current_watches", "pending_watches"],
1919
"description" : "Controls what additional stat metrics should be include in the response"
2020
},
2121
"emit_stacktraces": {

x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/stats/10_basic.yml

+52
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,55 @@
1212
emit_stacktraces: "true"
1313
- match: { "manually_stopped": false }
1414
- match: { "stats.0.watcher_state": "started" }
15+
16+
---
17+
"Test watcher stats current watches":
18+
- skip:
19+
version: " - 6.5.99"
20+
reason: metrics were fixed in 6.6.0
21+
22+
- do:
23+
xpack.watcher.stats:
24+
metric: "current_watches"
25+
26+
- is_false: stats.0.queued_watches
27+
- is_true: stats.0.current_watches
28+
29+
---
30+
"Test watcher stats queued watches":
31+
- skip:
32+
version: " - 6.5.99"
33+
reason: metrics were fixed in 6.6.0
34+
35+
- do:
36+
xpack.watcher.stats:
37+
metric: "queued_watches"
38+
39+
- is_false: stats.0.current_watches
40+
- is_true: stats.0.queued_watches
41+
42+
---
43+
"Test watcher stats queued watches using pending_watches":
44+
- skip:
45+
version: " - 6.5.99"
46+
reason: metrics were fixed in 6.6.0
47+
features: warnings
48+
49+
- do:
50+
warnings:
51+
- 'The pending_watches parameter is deprecated, use queued_watches instead'
52+
53+
xpack.watcher.stats:
54+
metric: "pending_watches"
55+
56+
- is_false: stats.0.current_watches
57+
- is_true: stats.0.queued_watches
58+
59+
---
60+
"Test watcher stats all watches":
61+
- do:
62+
xpack.watcher.stats:
63+
metric: "_all"
64+
65+
- is_true: stats.0.current_watches
66+
- is_true: stats.0.queued_watches

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ protected RestChannelConsumer doPrepareRequest(final RestRequest restRequest, Wa
5151
request.includeCurrentWatches(true);
5252
request.includeQueuedWatches(true);
5353
} else {
54-
request.includeCurrentWatches(metrics.contains("queued_watches"));
55-
request.includeQueuedWatches(metrics.contains("pending_watches"));
54+
request.includeCurrentWatches(metrics.contains("current_watches"));
55+
request.includeQueuedWatches(metrics.contains("queued_watches") || metrics.contains("pending_watches"));
56+
}
57+
58+
if (metrics.contains("pending_watches")) {
59+
deprecationLogger.deprecated("The pending_watches parameter is deprecated, use queued_watches instead");
5660
}
5761

5862

0 commit comments

Comments
 (0)