Skip to content

Commit 6bbcb33

Browse files
jasontedorkcm
authored andcommitted
Follow stats structure (#34301)
This commit modifies the follow stats API response structure to more clearly highlight meaning of the higher level fields. In particular, previously the response had a top-level key for each index. Instead, we nest the indices under an "indices" field which is now an array. The values in this array are objects containing two fields: "index" which is the name of the follower index, and "shards" which is an array where each value in the array is the follower stats for that shard. That is, we have gone from: { "bar": [ { "shard_id": 0... }... ]... } to { "indices": [ { "index": "bar", "shards": [ { "shard_id": 0... }... ] }... }
1 parent 1d5aa27 commit 6bbcb33

File tree

3 files changed

+74
-63
lines changed

3 files changed

+74
-63
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
"Test stats":
3+
- do:
4+
indices.create:
5+
index: foo
6+
body:
7+
settings:
8+
index:
9+
soft_deletes:
10+
enabled: true
11+
mappings:
12+
doc:
13+
properties:
14+
field:
15+
type: keyword
16+
17+
- do:
18+
ccr.follow:
19+
index: bar
20+
body:
21+
leader_index: foo
22+
- is_true: follow_index_created
23+
- is_true: follow_index_shards_acked
24+
- is_true: index_following_started
25+
26+
# we can not reliably wait for replication to occur so we test the endpoint without indexing any documents
27+
- do:
28+
ccr.stats:
29+
index: bar
30+
- match: { indices.0.index: "bar" }
31+
- match: { indices.0.shards.0.leader_index: "foo" }
32+
- match: { indices.0.shards.0.follower_index: "bar" }
33+
- match: { indices.0.shards.0.shard_id: 0 }
34+
- gte: { indices.0.shards.0.leader_global_checkpoint: -1 }
35+
- gte: { indices.0.shards.0.leader_max_seq_no: -1 }
36+
- gte: { indices.0.shards.0.follower_global_checkpoint: -1 }
37+
- gte: { indices.0.shards.0.follower_max_seq_no: -1 }
38+
- gte: { indices.0.shards.0.last_requested_seq_no: -1 }
39+
- gte: { indices.0.shards.0.number_of_concurrent_reads: 0 }
40+
- match: { indices.0.shards.0.number_of_concurrent_writes: 0 }
41+
- match: { indices.0.shards.0.number_of_queued_writes: 0 }
42+
- gte: { indices.0.shards.0.mapping_version: 0 }
43+
- gte: { indices.0.shards.0.total_fetch_time_millis: 0 }
44+
- gte: { indices.0.shards.0.number_of_successful_fetches: 0 }
45+
- gte: { indices.0.shards.0.number_of_failed_fetches: 0 }
46+
- match: { indices.0.shards.0.operations_received: 0 }
47+
- match: { indices.0.shards.0.total_transferred_bytes: 0 }
48+
- match: { indices.0.shards.0.total_index_time_millis: 0 }
49+
- match: { indices.0.shards.0.number_of_successful_bulk_operations: 0 }
50+
- match: { indices.0.shards.0.number_of_failed_bulk_operations: 0 }
51+
- match: { indices.0.shards.0.number_of_operations_indexed: 0 }
52+
- length: { indices.0.shards.0.fetch_exceptions: 0 }
53+
- gte: { indices.0.shards.0.time_since_last_fetch_millis: -1 }
54+
55+
- do:
56+
ccr.pause_follow:
57+
index: bar
58+
- is_true: acknowledged
59+

x-pack/plugin/ccr/qa/rest/src/test/resources/rest-api-spec/test/ccr/stats.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,24 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
7676
}
7777
builder.startObject();
7878
{
79-
for (final Map.Entry<String, Map<Integer, StatsResponse>> index : taskResponsesByIndex.entrySet()) {
80-
builder.startArray(index.getKey());
81-
{
82-
for (final Map.Entry<Integer, StatsResponse> shard : index.getValue().entrySet()) {
83-
shard.getValue().status().toXContent(builder, params);
79+
builder.startArray("indices");
80+
{
81+
for (final Map.Entry<String, Map<Integer, StatsResponse>> index : taskResponsesByIndex.entrySet()) {
82+
builder.startObject();
83+
{
84+
builder.field("index", index.getKey());
85+
builder.startArray("shards");
86+
{
87+
for (final Map.Entry<Integer, StatsResponse> shard : index.getValue().entrySet()) {
88+
shard.getValue().status().toXContent(builder, params);
89+
}
90+
}
91+
builder.endArray();
8492
}
93+
builder.endObject();
8594
}
86-
builder.endArray();
8795
}
96+
builder.endArray();
8897
}
8998
builder.endObject();
9099
return builder;

0 commit comments

Comments
 (0)