Use the newly added remote_cluster field for ccr (#25248)

This commit is contained in:
Chris Roberson 2018-11-07 09:04:28 -05:00 committed by GitHub
parent b5012d917d
commit 1acf855f2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,6 +87,7 @@ function buildRequest(req, config, esIndexPattern) {
'hits.hits.inner_hits.by_shard.hits.hits._source.ccr_stats.time_since_last_read_millis',
'aggregations.by_follower_index.buckets.key',
'aggregations.by_follower_index.buckets.leader_index.buckets.key',
'aggregations.by_follower_index.buckets.leader_index.buckets.remote_cluster.buckets.key',
'aggregations.by_follower_index.buckets.by_shard_id.buckets.key',
'aggregations.by_follower_index.buckets.by_shard_id.buckets.ops_synced.value',
'aggregations.by_follower_index.buckets.by_shard_id.buckets.lag_ops.value',
@ -139,6 +140,14 @@ function buildRequest(req, config, esIndexPattern) {
terms: {
field: 'ccr_stats.leader_index',
size: 1
},
aggs: {
remote_cluster: {
terms: {
field: 'ccr_stats.remote_cluster',
size: 1
}
}
}
},
by_shard_id: {
@ -200,12 +209,8 @@ export function ccrRoute(server) {
const buckets = get(response, 'aggregations.by_follower_index.buckets');
const data = buckets.reduce((accum, bucket) => {
const leaderIndex = get(bucket, 'leader_index.buckets[0].key');
let follows = leaderIndex;
if (follows.includes(':')) {
const followsSplit = follows.split(':');
follows = `${followsSplit[1]} on ${followsSplit[0]}`;
}
const remoteCluster = get(bucket, 'leader_index.buckets[0].remote_cluster.buckets[0].key');
const follows = remoteCluster ? `${leaderIndex} on ${remoteCluster}` : leaderIndex;
const stat = {
id: bucket.key,
index: bucket.key,