Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add follower badge to index management #29177

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}

};
8 changes: 7 additions & 1 deletion x-pack/plugins/cross_cluster_replication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
},
});
}
Original file line number Diff line number Diff line change
@@ -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);

1 change: 1 addition & 0 deletions x-pack/plugins/cross_cluster_replication/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

import './register_ccr_section';
import './register_routes';
import './extend_index_management';