diff --git a/x-pack/plugins/cross_cluster_replication/cross_cluster_replication_data.js b/x-pack/plugins/cross_cluster_replication/cross_cluster_replication_data.js new file mode 100644 index 000000000000..b9ecc52b0929 --- /dev/null +++ b/x-pack/plugins/cross_cluster_replication/cross_cluster_replication_data.js @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const ccrDataEnricher = async (indicesList, callWithRequest) => { + if (!indicesList || !indicesList.length) { + return indicesList; + } + const params = { + path: '/_all/_ccr/info', + method: 'GET', + }; + try { + const { follower_indices: followerIndices } = await callWithRequest('transport.request', params); + return indicesList.map(index => { + const isFollowerIndex = !!followerIndices.find((followerIndex) => { + return followerIndex.follower_index === index.name; + }); + return { + ...index, + isFollowerIndex + }; + }); + } catch (e) { + return indicesList; + } + +}; diff --git a/x-pack/plugins/cross_cluster_replication/index.js b/x-pack/plugins/cross_cluster_replication/index.js index 1424bd751ea6..c538ed78a85b 100644 --- a/x-pack/plugins/cross_cluster_replication/index.js +++ b/x-pack/plugins/cross_cluster_replication/index.js @@ -8,7 +8,8 @@ import { resolve } from 'path'; import { PLUGIN } from './common/constants'; import { registerLicenseChecker } from './server/lib/register_license_checker'; import { registerRoutes } from './server/routes/register_routes'; - +import { ccrDataEnricher } from './cross_cluster_replication_data'; +import { addIndexManagementDataEnricher } from '../index_management/index_management_data'; export function crossClusterReplication(kibana) { return new kibana.Plugin({ id: PLUGIN.ID, @@ -41,6 +42,11 @@ export function crossClusterReplication(kibana) { init: function initCcrPlugin(server) { registerLicenseChecker(server); registerRoutes(server); + if ( + server.config().get('xpack.ccr.ui.enabled') + ) { + addIndexManagementDataEnricher(ccrDataEnricher); + } }, }); } diff --git a/x-pack/plugins/cross_cluster_replication/public/extend_index_management/index.js b/x-pack/plugins/cross_cluster_replication/public/extend_index_management/index.js new file mode 100644 index 000000000000..4ee2e8908b70 --- /dev/null +++ b/x-pack/plugins/cross_cluster_replication/public/extend_index_management/index.js @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; +import { + addBadgeExtension +} from '../../../index_management/public/index_management_extensions'; +import { get } from 'lodash'; + +const propertyPath = 'isFollowerIndex'; +export const followerBadgeExtension = { + matchIndex: (index) => { + return get(index, propertyPath); + }, + label: i18n.translate('xpack.crossClusterReplication.indexMgmtBadge.followerLabel', { + defaultMessage: 'Follower', + }), + color: 'default' +}; + +addBadgeExtension(followerBadgeExtension); + diff --git a/x-pack/plugins/cross_cluster_replication/public/index.js b/x-pack/plugins/cross_cluster_replication/public/index.js index d9e036d2dfbf..b4bf57ec47f7 100644 --- a/x-pack/plugins/cross_cluster_replication/public/index.js +++ b/x-pack/plugins/cross_cluster_replication/public/index.js @@ -6,3 +6,4 @@ import './register_ccr_section'; import './register_routes'; +import './extend_index_management';