Skip to content

Commit 7e58aa6

Browse files
authored
Changing name of shards field in node/stats api to shard_stats #78531 (#78803)
If the _nodes/stats API received a level=shards request parameter, then the response would have two "shards" fields, which would cause problems with json parsers. This commit renames the "shards" field that currently only contains "total_count" to "shard_stats". Relates #78311 #75433 #78531
1 parent 6216ec2 commit 7e58aa6

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

docs/reference/cluster/nodes-stats.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,11 @@ Time in milliseconds
960960
recovery operations were delayed due to throttling.
961961
=======
962962
963-
`shards`::
963+
`shards_stats`::
964964
(object)
965965
Contains statistics about all shards assigned to the node.
966966
+
967-
.Properties of `shards`
967+
.Properties of `shard_stats`
968968
[%collapsible%open]
969969
=======
970970
`total_count`::

rest-api-spec/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
apply plugin: 'elasticsearch.build'
24
apply plugin: 'elasticsearch.publish'
35
apply plugin: 'elasticsearch.rest-resources'

rest-api-spec/src/main/resources/rest-api-spec/api/nodes.stats.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"store",
129129
"warmer",
130130
"suggest",
131-
"shards"
131+
"shard_stats"
132132
],
133133
"description":"Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified."
134134
}
@@ -177,7 +177,7 @@
177177
"store",
178178
"warmer",
179179
"suggest",
180-
"shards"
180+
"shard_stats"
181181
],
182182
"description":"Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified."
183183
},

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
- is_false: nodes.$node_id.indices.segments
110110
- is_false: nodes.$node_id.indices.translog
111111
- is_false: nodes.$node_id.indices.recovery
112-
- is_false: nodes.$node_id.indices.shards
112+
- is_false: nodes.$node_id.indices.shard_stats
113113

114114
---
115115
"Metric - multi":
@@ -167,7 +167,7 @@
167167
- is_false: nodes.$node_id.indices.segments
168168
- is_false: nodes.$node_id.indices.translog
169169
- is_true: nodes.$node_id.indices.recovery
170-
- is_false: nodes.$node_id.indices.shards
170+
- is_false: nodes.$node_id.indices.shard_stats
171171

172172
---
173173
"Metric - _all include_segment_file_sizes":
@@ -225,7 +225,7 @@
225225
- is_true: nodes.$node_id.indices.segments
226226
- is_false: nodes.$node_id.indices.translog
227227
- is_false: nodes.$node_id.indices.recovery
228-
- is_false: nodes.$node_id.indices.shards
228+
- is_false: nodes.$node_id.indices.shard_stats
229229
- is_true: nodes.$node_id.indices.segments.file_sizes
230230

231231
---
@@ -257,7 +257,7 @@
257257
- is_true: nodes.$node_id.indices.segments
258258
- is_false: nodes.$node_id.indices.translog
259259
- is_false: nodes.$node_id.indices.recovery
260-
- is_false: nodes.$node_id.indices.shards
260+
- is_false: nodes.$node_id.indices.shard_stats
261261

262262
---
263263
"Metric - _all include_unloaded_segments":
@@ -321,11 +321,11 @@
321321
# null and cannot be tested here
322322

323323
---
324-
"Metric - blank for indices shards":
324+
"Metric - blank for indices shard_stats":
325325
- skip:
326326
features: [arbitrary_key]
327-
version: " - 7.14.99"
328-
reason: "total shard count added in version 7.15.0"
327+
version: " - 7.15.0"
328+
reason: "total shard count added in version 7.15.0, and fixed in 7.15.1"
329329
- do:
330330
nodes.info: {}
331331
- set:
@@ -334,15 +334,15 @@
334334
- do:
335335
nodes.stats: {}
336336

337-
- is_true: nodes.$node_id.indices.shards
338-
- match: { nodes.$node_id.indices.shards.total_count: 0 }
337+
- is_true: nodes.$node_id.indices.shard_stats
338+
- match: { nodes.$node_id.indices.shard_stats.total_count: 0 }
339339

340340
---
341-
"Metric - _all for indices shards":
341+
"Metric - _all for indices shard_stats":
342342
- skip:
343343
features: [arbitrary_key]
344-
version: " - 7.14.99"
345-
reason: "total shard count added in version 7.15.0"
344+
version: " - 7.15.0"
345+
reason: "total shard count added in version 7.15.0, and fixed in 7.15.1"
346346
- do:
347347
nodes.info: {}
348348
- set:
@@ -351,17 +351,17 @@
351351
- do:
352352
nodes.stats: { metric: _all }
353353

354-
- is_true: nodes.$node_id.indices.shards
355-
- match: { nodes.$node_id.indices.shards.total_count: 0 }
354+
- is_true: nodes.$node_id.indices.shard_stats
355+
- match: { nodes.$node_id.indices.shard_stats.total_count: 0 }
356356

357357

358358
---
359-
"indices shards total count test":
359+
"indices shard_stats total count test":
360360

361361
- skip:
362362
features: ["allowed_warnings", arbitrary_key]
363-
version: " - 7.14.99"
364-
reason: "total shard count added in version 7.15.0"
363+
version: " - 7.15.0"
364+
reason: "total shard count added in version 7.15.0, and fixed in 7.15.1"
365365

366366
- do:
367367
indices.create:
@@ -387,4 +387,4 @@
387387
- do:
388388
nodes.stats: { metric: _all }
389389

390-
- gte: { nodes.$node_id.indices.shards.total_count: 1 }
390+
- gte: { nodes.$node_id.indices.shard_stats.total_count: 1 }

server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public enum Flag {
232232
// 14 was previously used for Suggest
233233
RequestCache("request_cache", 15),
234234
Recovery("recovery", 16),
235-
Shards("shards", 18);
235+
Shards("shard_stats", 18);
236236

237237
private final String restName;
238238
private final int index;

server/src/main/java/org/elasticsearch/index/shard/ShardCountStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void writeTo(StreamOutput out) throws IOException {
5656
}
5757

5858
static final class Fields {
59-
static final String SHARDS = "shards";
59+
static final String SHARDS = "shard_stats";
6060
static final String TOTAL_COUNT = "total_count";
6161
}
6262

0 commit comments

Comments
 (0)