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

[Monitoring] Add flag to enable/disable CCR monitoring UI #28840

Merged
merged 17 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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
Expand Up @@ -64,7 +64,7 @@
i18n-default-message="Jobs"
></a>
<a
ng-if="!monitoringMain.instance"
ng-if="(monitoringMain.isCcrEnabled || monitoringMain.isActiveTab('ccr')) && !monitoringMain.instance"
kbn-href="#/elasticsearch/ccr"
class="kuiLocalTab"
ng-class="{'kuiLocalTab-isSelected': monitoringMain.isActiveTab('ccr')}"
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/monitoring/public/directives/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ uiModule.directive('monitoringMain', (breadcrumbs, license, kbnUrl, config) => {
config.watch('k7design', (val) => scope.showPluginBreadcrumbs = !val);

function getSetupObj() {
console.log(attributes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to leave this in? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all! Thanks!

return {
licenseService: license,
breadcrumbsService: breadcrumbs,
Expand All @@ -97,7 +98,8 @@ uiModule.directive('monitoringMain', (breadcrumbs, license, kbnUrl, config) => {
tabIconLabel: attributes.tabIconLabel,
pipelineId: attributes.pipelineId,
pipelineHash: attributes.pipelineHash,
pipelineVersions: get(scope, 'pageData.versions')
pipelineVersions: get(scope, 'pageData.versions'),
isCcrEnabled: attributes.isCcrEnabled
},
clusterName: get(scope, 'cluster.cluster_name')
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<monitoring-main
product="elasticsearch"
name="indices"
is-ccr-enabled="{{ elasticsearchIndices.isCcrEnabled }}"
data-test-subj="elasticsearchIndicesListingPage"
>
<div id="elasticsearchIndicesReact"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ uiRoutes.when('/elasticsearch/indices', {
$injector
});

this.isCcrEnabled = $scope.cluster.isCcrEnabled;

// for binding
const toggleShowSystemIndices = isChecked => {
// flip the boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<monitoring-main
product="elasticsearch"
name="nodes"
is-ccr-enabled="{{ elasticsearchNodes.isCcrEnabled }}"
data-test-subj="elasticsearchNodesListingPage"
>
<div id="elasticsearchNodesReact"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ uiRoutes.when('/elasticsearch/nodes', {
$injector
});

this.isCcrEnabled = $scope.cluster.isCcrEnabled;

$scope.$watch(() => this.data, data => {
this.renderReact(data);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class ElasticsearchOverviewController extends MonitoringViewBaseControlle
$injector
});

this.isCcrEnabled = $scope.cluster.isCcrEnabled;
this.showShardActivityHistory = false;
this.toggleShardActivityHistory = () => {
this.showShardActivityHistory = !this.showShardActivityHistory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<monitoring-main
product="elasticsearch"
name="overview"
is-ccr-enabled="{{ elasticsearchOverview.isCcrEnabled }}"
data-test-subj="elasticsearchOverviewPage"
>
<div id="elasticsearchOverviewReact"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Array [
"status": "green",
},
},
"isCcrEnabled": undefined,
"isPrimary": true,
"isSupported": true,
"kibana": Object {
Expand Down Expand Up @@ -176,6 +177,7 @@ Array [
"status": "green",
},
},
"isCcrEnabled": undefined,
"isPrimary": false,
"isSupported": true,
"kibana": Object {
Expand Down Expand Up @@ -283,6 +285,7 @@ Array [
"status": "green",
},
},
"isCcrEnabled": undefined,
"isPrimary": false,
"isSupported": true,
"kibana": Object {
Expand Down Expand Up @@ -385,6 +388,7 @@ Array [
"status": "green",
},
},
"isCcrEnabled": undefined,
"isPrimary": false,
"isSupported": true,
"kibana": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { getClustersSummary } from './get_clusters_summary';
import { CLUSTER_ALERTS_SEARCH_SIZE } from '../../../common/constants';
import { getApmsForClusters } from '../apm/get_apms_for_clusters';
import { i18n } from '@kbn/i18n';
import { checkCcrEnabled } from '../elasticsearch/ccr';

/**
* Get all clusters or the cluster associated with {@code clusterUuid} when it is defined.
Expand Down Expand Up @@ -127,7 +128,10 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid,
set(clusters[clusterIndex], 'apm', apm.stats);
});

// check ccr configuration
const isCcrEnabled = await checkCcrEnabled(req);

const config = req.server.config();
const kibanaUuid = config.get('server.uuid');
return getClustersSummary(clusters, kibanaUuid);
return getClustersSummary(clusters, kibanaUuid, isCcrEnabled);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { pick, omit, get } from 'lodash';
import { calculateOverallStatus } from '../calculate_overall_status';

export function getClustersSummary(clusters, kibanaUuid) {
export function getClustersSummary(clusters, kibanaUuid, isCcrEnabled) {
return clusters.map(cluster => {
const {
isSupported,
Expand Down Expand Up @@ -77,7 +77,8 @@ export function getClustersSummary(clusters, kibanaUuid) {
status: calculateOverallStatus([
status,
kibana && kibana.status || null
])
]),
isCcrEnabled
};
});
}
24 changes: 24 additions & 0 deletions x-pack/plugins/monitoring/server/lib/elasticsearch/ccr.js
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 { get } from 'lodash';

export function handleResponse(response) {
return get(response.defaults, 'xpack.ccr.enabled') === 'true';
}

export async function checkCcrEnabled(req) {
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('monitoring');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right cluster to check against? Or is it admin? @pickypg

Copy link
Contributor

@ycombinator ycombinator Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah crap, of course! We can't just call this API against the production or monitoring clusters 🤦‍♂️. What we need is to know via monitoring data if CCR is enabled or disabled on a particular production cluster. I'm not sure we have the data on whether CCR is enabled or not in .monitoring-es-*.

Copy link
Contributor

@ycombinator ycombinator Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will automatically start collecting this information in cluster_stats documents under the stack_stats.xpack.ccr.* field once elastic/elasticsearch#37256 is merged. Until then we can update the code in this PR to look at this field to make the determination whether to show the CCR tab or not.

const response = await callWithRequest(req, 'transport.request', {
method: 'GET',
path: '/_cluster/settings?include_defaults',
filter_path: [
'defaults.xpack.ccr.enabled',
]
ycombinator marked this conversation as resolved.
Show resolved Hide resolved
});

return handleResponse(response);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function esIndicesRoute(server) {

return {
clusterStatus: getClusterStatus(clusterStats, shardStats),
indices
indices,
};
} catch(err) {
throw handleError(err, req);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function esNodesRoute(server) {
const clusterStatus = getClusterStatus(clusterStats, shardStats);
const nodes = await getNodes(req, esIndexPattern, clusterStats, shardStats);

return { clusterStatus, nodes, };
return { clusterStatus, nodes };
} catch(err) {
throw handleError(err, req);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function esOverviewRoute(server) {
return {
clusterStatus: getClusterStatus(clusterStats, shardStats),
metrics,
shardActivity
shardActivity,
};
} catch (err) {
throw handleError(err, req);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"message": "Cluster [clustertwo] license type [basic] does not support Cluster Alerts"
}
},
"isCcrEnabled": true,
"isPrimary": false,
"status": "green"
},
Expand Down Expand Up @@ -225,6 +226,7 @@
"medium": 1,
"high": 0
},
"isCcrEnabled": true,
"isPrimary": false,
"status": "yellow"
},
Expand Down Expand Up @@ -338,6 +340,7 @@
"enabled": true
}
},
"isCcrEnabled": true,
"isPrimary": false,
"status": "green"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"timestamp": "2017-08-23T21:28:25.639Z"
}
],
"isCcrEnabled": true,
"isPrimary": true,
"status": "green"
}
Expand Down