Skip to content

Commit 901d803

Browse files
[CCR] Update es monitoring mapping and (#33635)
* [CCR] Update es monitoring mapping and change qa tests to query based on leader index. Co-authored-by: Jason Tedor <[email protected]>
1 parent c783488 commit 901d803

File tree

3 files changed

+89
-16
lines changed

3 files changed

+89
-16
lines changed

x-pack/plugin/ccr/qa/multi-cluster-with-security/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexSecurityIT.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
3030
import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
3131
import static org.hamcrest.Matchers.containsString;
32+
import static org.hamcrest.Matchers.endsWith;
3233
import static org.hamcrest.Matchers.equalTo;
3334
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
3435
import static org.hamcrest.Matchers.is;
@@ -209,22 +210,19 @@ private static void verifyCcrMonitoring(String expectedLeaderIndex) throws IOExc
209210
ensureYellow(".monitoring-*");
210211

211212
Request request = new Request("GET", "/.monitoring-*/_search");
212-
request.setJsonEntity("{\"query\": {\"term\": {\"type\": \"ccr_stats\"}}}");
213+
request.setJsonEntity("{\"query\": {\"term\": {\"ccr_stats.leader_index\": \"leader_cluster:" + expectedLeaderIndex + "\"}}}");
213214
Map<String, ?> response = toMap(adminClient().performRequest(request));
214215

215-
int numDocs = (int) XContentMapValues.extractValue("hits.total", response);
216-
assertThat(numDocs, greaterThanOrEqualTo(1));
217-
218216
int numberOfOperationsReceived = 0;
219217
int numberOfOperationsIndexed = 0;
220218

221219
List<?> hits = (List<?>) XContentMapValues.extractValue("hits.hits", response);
222-
for (int i = 0; i < numDocs; i++) {
220+
assertThat(hits.size(), greaterThanOrEqualTo(1));
221+
222+
for (int i = 0; i < hits.size(); i++) {
223223
Map<?, ?> hit = (Map<?, ?>) hits.get(i);
224224
String leaderIndex = (String) XContentMapValues.extractValue("_source.ccr_stats.leader_index", hit);
225-
if (leaderIndex.endsWith(expectedLeaderIndex) == false) {
226-
continue;
227-
}
225+
assertThat(leaderIndex, endsWith(leaderIndex));
228226

229227
int foundNumberOfOperationsReceived =
230228
(int) XContentMapValues.extractValue("_source.ccr_stats.operations_received", hit);

x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Map;
2525

2626
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
27+
import static org.hamcrest.Matchers.endsWith;
2728
import static org.hamcrest.Matchers.equalTo;
2829
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
2930

@@ -162,22 +163,19 @@ private static void verifyCcrMonitoring(String expectedLeaderIndex) throws IOExc
162163
ensureYellow(".monitoring-*");
163164

164165
Request request = new Request("GET", "/.monitoring-*/_search");
165-
request.setJsonEntity("{\"query\": {\"term\": {\"type\": \"ccr_stats\"}}}");
166+
request.setJsonEntity("{\"query\": {\"term\": {\"ccr_stats.leader_index\": \"leader_cluster:" + expectedLeaderIndex + "\"}}}");
166167
Map<String, ?> response = toMap(client().performRequest(request));
167168

168-
int numDocs = (int) XContentMapValues.extractValue("hits.total", response);
169-
assertThat(numDocs, greaterThanOrEqualTo(1));
170-
171169
int numberOfOperationsReceived = 0;
172170
int numberOfOperationsIndexed = 0;
173171

174172
List<?> hits = (List<?>) XContentMapValues.extractValue("hits.hits", response);
175-
for (int i = 0; i < numDocs; i++) {
173+
assertThat(hits.size(), greaterThanOrEqualTo(1));
174+
175+
for (int i = 0; i < hits.size(); i++) {
176176
Map<?, ?> hit = (Map<?, ?>) hits.get(i);
177177
String leaderIndex = (String) XContentMapValues.extractValue("_source.ccr_stats.leader_index", hit);
178-
if (leaderIndex.endsWith(expectedLeaderIndex) == false) {
179-
continue;
180-
}
178+
assertThat(leaderIndex, endsWith(leaderIndex));
181179

182180
int foundNumberOfOperationsReceived =
183181
(int) XContentMapValues.extractValue("_source.ccr_stats.operations_received", hit);

x-pack/plugin/core/src/main/resources/monitoring-es.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,83 @@
916916
}
917917
}
918918
}
919+
},
920+
"ccr_stats": {
921+
"properties": {
922+
"leader_index": {
923+
"type": "keyword"
924+
},
925+
"shard_id": {
926+
"type": "integer"
927+
},
928+
"leader_global_checkpoint": {
929+
"type": "long"
930+
},
931+
"leader_max_seq_no": {
932+
"type": "long"
933+
},
934+
"follower_global_checkpoint": {
935+
"type": "long"
936+
},
937+
"follower_max_seq_no": {
938+
"type": "long"
939+
},
940+
"last_requested_seq_no": {
941+
"type": "long"
942+
},
943+
"number_of_concurrent_reads": {
944+
"type": "long"
945+
},
946+
"number_of_concurrent_writes": {
947+
"type": "long"
948+
},
949+
"number_of_queued_writes": {
950+
"type": "long"
951+
},
952+
"mapping_version": {
953+
"type": "long"
954+
},
955+
"total_fetch_time_millis": {
956+
"type": "long"
957+
},
958+
"number_of_successful_fetches": {
959+
"type": "long"
960+
},
961+
"number_of_failed_fetches": {
962+
"type": "long"
963+
},
964+
"operations_received": {
965+
"type": "long"
966+
},
967+
"total_transferred_bytes": {
968+
"type": "long"
969+
},
970+
"total_index_time_millis": {
971+
"type": "long"
972+
},
973+
"number_of_successful_bulk_operations": {
974+
"type": "long"
975+
},
976+
"number_of_failed_bulk_operations": {
977+
"type": "long"
978+
},
979+
"number_of_operations_indexed": {
980+
"type": "long"
981+
},
982+
"fetch_exceptions": {
983+
"properties": {
984+
"from_seq_no": {
985+
"type": "long"
986+
},
987+
"exception": {
988+
"type": "text"
989+
}
990+
}
991+
},
992+
"time_since_last_fetch_millis": {
993+
"type": "long"
994+
}
995+
}
919996
}
920997
}
921998
}

0 commit comments

Comments
 (0)