mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Monitoring] Only fetch a single cluster data instead of all clusters when possible (#42469)
* Fetch a single cluster if it's in the global state * Potential solution * PR feedback * Fix tests
This commit is contained in:
parent
53abbcdc9c
commit
36f0d41133
45 changed files with 193 additions and 82 deletions
|
@ -172,3 +172,21 @@ export const APM_CUSTOM_ID = 'apm';
|
|||
* The id of the infra source owned by the monitoring plugin.
|
||||
*/
|
||||
export const INFRA_SOURCE_ID = 'internal-stack-monitoring';
|
||||
|
||||
/*
|
||||
* These constants represent code paths within `getClustersFromRequest`
|
||||
* that an api call wants to invoke. This is meant as an optimization to
|
||||
* avoid unnecessary ES queries (looking at you logstash) when the data
|
||||
* is not used. In the long term, it'd be nice to have separate api calls
|
||||
* instead of this path logic.
|
||||
*/
|
||||
export const CODE_PATH_ALL = 'all';
|
||||
export const CODE_PATH_ALERTS = 'alerts';
|
||||
export const CODE_PATH_KIBANA = 'kibana';
|
||||
export const CODE_PATH_ELASTICSEARCH = 'elasticsearch';
|
||||
export const CODE_PATH_ML = 'ml';
|
||||
export const CODE_PATH_BEATS = 'beats';
|
||||
export const CODE_PATH_LOGSTASH = 'logstash';
|
||||
export const CODE_PATH_APM = 'apm';
|
||||
export const CODE_PATH_LICENSE = 'license';
|
||||
export const CODE_PATH_LOGS = 'logs';
|
||||
|
|
|
@ -22,8 +22,9 @@ export function routeInitProvider(Private, monitoringClusters, globalState, lice
|
|||
* the data just has a single cluster or
|
||||
* all the clusters are basic and this is the primary cluster
|
||||
*/
|
||||
return function routeInit() {
|
||||
return monitoringClusters()
|
||||
return function routeInit({ codePaths }) {
|
||||
const clusterUuid = globalState.cluster_uuid;
|
||||
return monitoringClusters(clusterUuid, undefined, codePaths)
|
||||
// Set the clusters collection and current cluster in globalState
|
||||
.then((clusters) => {
|
||||
const inSetupMode = getSetupModeState().enabled;
|
||||
|
@ -41,7 +42,8 @@ export function routeInitProvider(Private, monitoringClusters, globalState, lice
|
|||
}
|
||||
|
||||
// check if we need to redirect because of attempt at unsupported multi-cluster monitoring
|
||||
if (!isOnPage('home') && !cluster.isSupported) {
|
||||
const clusterSupported = cluster.isSupported || clusters.length === 1;
|
||||
if (!isOnPage('home') && !clusterSupported) {
|
||||
return kbnUrl.redirect('/home');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ function formatCluster(cluster) {
|
|||
|
||||
const uiModule = uiModules.get('monitoring/clusters');
|
||||
uiModule.service('monitoringClusters', ($injector) => {
|
||||
return (clusterUuid, ccs) => {
|
||||
return (clusterUuid, ccs, codePaths) => {
|
||||
const { min, max } = timefilter.getBounds();
|
||||
|
||||
// append clusterUuid if the parameter is given
|
||||
|
@ -37,13 +37,11 @@ uiModule.service('monitoringClusters', ($injector) => {
|
|||
timeRange: {
|
||||
min: min.toISOString(),
|
||||
max: max.toISOString()
|
||||
}
|
||||
},
|
||||
codePaths
|
||||
})
|
||||
.then(response => response.data)
|
||||
.then(data => {
|
||||
if (clusterUuid) {
|
||||
return formatCluster(data[0]); // return single cluster
|
||||
}
|
||||
return formatClusters(data); // return set of clusters
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
|
@ -18,6 +18,7 @@ import { Alerts } from '../../components/alerts';
|
|||
import { MonitoringViewBaseEuiTableController } from '../base_eui_table_controller';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { EuiPage, EuiPageBody, EuiPageContent, EuiSpacer, EuiLink } from '@elastic/eui';
|
||||
import { CODE_PATH_ALERTS } from '../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const globalState = $injector.get('globalState');
|
||||
|
@ -46,7 +47,7 @@ uiRoutes.when('/alerts', {
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ALERTS] });
|
||||
},
|
||||
alerts: getPageData
|
||||
},
|
||||
|
|
|
@ -19,13 +19,14 @@ import template from './index.html';
|
|||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { ApmServerInstance } from '../../../components/apm/instance';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { CODE_PATH_APM } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/apm/instances/:uuid', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_APM] });
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@ import { ApmServerInstances } from '../../../components/apm/instances';
|
|||
import { MonitoringViewBaseEuiTableController } from '../..';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { SetupModeRenderer } from '../../../components/renderers';
|
||||
import { APM_CUSTOM_ID } from '../../../../common/constants';
|
||||
import { APM_CUSTOM_ID, CODE_PATH_APM } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/apm/instances', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_APM] });
|
||||
},
|
||||
},
|
||||
controller: class extends MonitoringViewBaseEuiTableController {
|
||||
|
|
|
@ -12,13 +12,14 @@ import template from './index.html';
|
|||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { ApmOverview } from '../../../components/apm/overview';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { CODE_PATH_APM } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/apm', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_APM] });
|
||||
},
|
||||
},
|
||||
controller: class extends MonitoringViewBaseController {
|
||||
|
|
|
@ -11,13 +11,14 @@ import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
|||
import { MonitoringViewBaseController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
import template from './index.html';
|
||||
import { CODE_PATH_BEATS } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/beats/beat/:beatUuid', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_BEATS] });
|
||||
},
|
||||
pageData: getPageData,
|
||||
},
|
||||
|
|
|
@ -16,13 +16,14 @@ import { I18nContext } from 'ui/i18n';
|
|||
import { Listing } from '../../../components/beats/listing/listing';
|
||||
import { SetupModeRenderer } from '../../../components/renderers';
|
||||
import { BEATS_SYSTEM_ID } from '../../../../../telemetry/common/constants';
|
||||
import { CODE_PATH_BEATS } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/beats/beats', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_BEATS] });
|
||||
},
|
||||
pageData: getPageData,
|
||||
},
|
||||
|
|
|
@ -11,13 +11,14 @@ import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
|||
import { MonitoringViewBaseController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
import template from './index.html';
|
||||
import { CODE_PATH_BEATS } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/beats', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_BEATS] });
|
||||
},
|
||||
pageData: getPageData,
|
||||
},
|
||||
|
|
|
@ -11,10 +11,13 @@ import { MonitoringViewBaseEuiTableController } from '../../';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import template from './index.html';
|
||||
import { Listing } from '../../../components/cluster/listing';
|
||||
import { CODE_PATH_ALL } from '../../../../common/constants';
|
||||
|
||||
const CODE_PATHS = [CODE_PATH_ALL];
|
||||
|
||||
const getPageData = $injector => {
|
||||
const monitoringClusters = $injector.get('monitoringClusters');
|
||||
return monitoringClusters();
|
||||
return monitoringClusters(undefined, undefined, CODE_PATHS);
|
||||
};
|
||||
|
||||
uiRoutes.when('/home', {
|
||||
|
@ -22,7 +25,7 @@ uiRoutes.when('/home', {
|
|||
resolve: {
|
||||
clusters: (Private, kbnUrl) => {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit()
|
||||
return routeInit({ codePaths: CODE_PATHS })
|
||||
.then(clusters => {
|
||||
if (!clusters || !clusters.length) {
|
||||
kbnUrl.changePath('/no-data');
|
||||
|
|
|
@ -12,6 +12,9 @@ import { MonitoringViewBaseController } from '../../';
|
|||
import { Overview } from 'plugins/monitoring/components/cluster/overview';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { SetupModeRenderer } from '../../../components/renderers';
|
||||
import { CODE_PATH_ALL } from '../../../../common/constants';
|
||||
|
||||
const CODE_PATHS = [CODE_PATH_ALL];
|
||||
|
||||
uiRoutes.when('/overview', {
|
||||
template,
|
||||
|
@ -19,10 +22,7 @@ uiRoutes.when('/overview', {
|
|||
clusters(Private) {
|
||||
// checks license info of all monitored clusters for multi-cluster monitoring usage and capability
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
},
|
||||
cluster(monitoringClusters, globalState) {
|
||||
return monitoringClusters(globalState.cluster_uuid, globalState.ccs);
|
||||
return routeInit({ codePaths: CODE_PATHS });
|
||||
}
|
||||
},
|
||||
controller: class extends MonitoringViewBaseController {
|
||||
|
@ -36,7 +36,10 @@ uiRoutes.when('/overview', {
|
|||
defaultMessage: 'Overview'
|
||||
}),
|
||||
defaultData: {},
|
||||
getPageData: () => monitoringClusters(globalState.cluster_uuid, globalState.ccs),
|
||||
getPageData: async () => {
|
||||
const clusters = await monitoringClusters(globalState.cluster_uuid, globalState.ccs, CODE_PATHS);
|
||||
return clusters[0];
|
||||
},
|
||||
reactNodeId: 'monitoringClusterOverviewApp',
|
||||
$scope,
|
||||
$injector
|
||||
|
|
|
@ -13,13 +13,14 @@ import template from './index.html';
|
|||
import { Ccr } from '../../../components/elasticsearch/ccr';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch/ccr', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
},
|
||||
pageData: getPageData,
|
||||
},
|
||||
|
|
|
@ -14,13 +14,14 @@ import template from './index.html';
|
|||
import { MonitoringViewBaseController } from '../../../base_controller';
|
||||
import { CcrShard } from '../../../../components/elasticsearch/ccr_shard';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch/ccr/:index/shard/:shardId', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
},
|
||||
pageData: getPageData,
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@ import { timefilter } from 'ui/timefilter';
|
|||
import { AdvancedIndex } from '../../../../components/elasticsearch/index/advanced';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { MonitoringViewBaseController } from '../../../base_controller';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const globalState = $injector.get('globalState');
|
||||
|
@ -46,7 +47,7 @@ uiRoutes.when('/elasticsearch/indices/:index/advanced', {
|
|||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ import { labels } from '../../../components/elasticsearch/shard_allocation/lib/l
|
|||
import { indicesByNodes } from '../../../components/elasticsearch/shard_allocation/transformers/indices_by_nodes';
|
||||
import { Index } from '../../../components/elasticsearch/index/index';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -48,7 +49,7 @@ uiRoutes.when('/elasticsearch/indices/:index', {
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -13,13 +13,14 @@ import { MonitoringViewBaseEuiTableController } from '../../';
|
|||
import { ElasticsearchIndices } from '../../../components';
|
||||
import template from './index.html';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch/indices', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
}
|
||||
},
|
||||
controllerAs: 'elasticsearchIndices',
|
||||
|
|
|
@ -11,13 +11,14 @@ import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
|||
import { MonitoringViewBaseEuiTableController } from '../../';
|
||||
import { getPageData } from './get_page_data';
|
||||
import template from './index.html';
|
||||
import { CODE_PATH_ELASTICSEARCH, CODE_PATH_ML } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch/ml_jobs', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH, CODE_PATH_ML] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@ import { timefilter } from 'ui/timefilter';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import { AdvancedNode } from '../../../../components/elasticsearch/node/advanced';
|
||||
import { MonitoringViewBaseController } from '../../../base_controller';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -46,7 +47,7 @@ uiRoutes.when('/elasticsearch/nodes/:node/advanced', {
|
|||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -19,13 +19,14 @@ import { I18nContext } from 'ui/i18n';
|
|||
import { labels } from '../../../components/elasticsearch/shard_allocation/lib/labels';
|
||||
import { nodesByIndices } from '../../../components/elasticsearch/shard_allocation/transformers/nodes_by_indices';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch/nodes/:node', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -16,14 +16,14 @@ import { ElasticsearchNodes } from '../../../components';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import { ajaxErrorHandlersProvider } from '../../../lib/ajax_error_handler';
|
||||
import { SetupModeRenderer } from '../../../components/renderers';
|
||||
import { ELASTICSEARCH_CUSTOM_ID } from '../../../../common/constants';
|
||||
import { ELASTICSEARCH_CUSTOM_ID, CODE_PATH_ELASTICSEARCH } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch/nodes', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
}
|
||||
},
|
||||
controllerAs: 'elasticsearchNodes',
|
||||
|
|
|
@ -8,13 +8,14 @@ import uiRoutes from 'ui/routes';
|
|||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { ElasticsearchOverviewController } from './controller';
|
||||
import { CODE_PATH_ELASTICSEARCH } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/elasticsearch', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_ELASTICSEARCH] });
|
||||
}
|
||||
},
|
||||
controllerAs: 'elasticsearchOverview',
|
||||
|
|
|
@ -19,6 +19,7 @@ import { MonitoringTimeseriesContainer } from '../../../components/chart';
|
|||
import { DetailStatus } from 'plugins/monitoring/components/kibana/detail_status';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { CODE_PATH_KIBANA } from '../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -47,7 +48,7 @@ uiRoutes.when('/kibana/instances/:uuid', {
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_KIBANA] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -14,13 +14,14 @@ import { KibanaInstances } from 'plugins/monitoring/components/kibana/instances'
|
|||
import { SetupModeRenderer } from '../../../components/renderers';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { KIBANA_SYSTEM_ID } from '../../../../../telemetry/common/constants';
|
||||
import { CODE_PATH_KIBANA } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/kibana/instances', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_KIBANA] });
|
||||
},
|
||||
pageData: getPageData,
|
||||
},
|
||||
|
|
|
@ -18,6 +18,7 @@ import { EuiPage, EuiPageBody, EuiPageContent, EuiPanel, EuiSpacer, EuiFlexGroup
|
|||
import { ClusterStatus } from '../../../components/kibana/cluster_status';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { CODE_PATH_KIBANA } from '../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -45,7 +46,7 @@ uiRoutes.when('/kibana', {
|
|||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_KIBANA] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -8,13 +8,14 @@ import uiRoutes from 'ui/routes';
|
|||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import template from './index.html';
|
||||
import { LicenseViewController } from './controller';
|
||||
import { CODE_PATH_LICENSE } from '../../../common/constants';
|
||||
|
||||
uiRoutes.when('/license', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters: (Private) => {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LICENSE] });
|
||||
}
|
||||
},
|
||||
controllerAs: 'licenseView',
|
||||
|
|
|
@ -11,6 +11,7 @@ import uiRoutes from 'ui/routes';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import template from './index.html';
|
||||
import { toggleSetupMode, getSetupModeState, initSetupModeState } from '../../lib/setup_mode';
|
||||
import { CODE_PATH_LICENSE } from '../../../common/constants';
|
||||
|
||||
const REACT_DOM_ID = 'monitoringLoadingReactApp';
|
||||
|
||||
|
@ -41,7 +42,7 @@ uiRoutes
|
|||
this.renderReact();
|
||||
});
|
||||
|
||||
monitoringClusters()
|
||||
monitoringClusters(undefined, undefined, [CODE_PATH_LICENSE])
|
||||
.then(clusters => {
|
||||
if (clusters && clusters.length) {
|
||||
kbnUrl.changePath('/home');
|
||||
|
|
|
@ -19,6 +19,7 @@ import { DetailStatus } from 'plugins/monitoring/components/logstash/detail_stat
|
|||
import { EuiPage, EuiPageBody, EuiPageContent, EuiPanel, EuiSpacer, EuiFlexGrid, EuiFlexItem } from '@elastic/eui';
|
||||
import { MonitoringTimeseriesContainer } from '../../../../components/chart';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { CODE_PATH_LOGSTASH } from '../../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -48,7 +49,7 @@ uiRoutes.when('/logstash/node/:uuid/advanced', {
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ import { EuiPage, EuiPageBody, EuiPageContent, EuiPanel, EuiSpacer, EuiFlexGrid,
|
|||
import { MonitoringTimeseriesContainer } from '../../../components/chart';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { CODE_PATH_LOGSTASH } from '../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -48,7 +49,7 @@ uiRoutes.when('/logstash/node/:uuid', {
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -22,6 +22,7 @@ import { MonitoringViewBaseEuiTableController } from '../../../';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import { PipelineListing } from '../../../../components/logstash/pipeline_listing/pipeline_listing';
|
||||
import { DetailStatus } from '../../../../components/logstash/detail_status';
|
||||
import { CODE_PATH_LOGSTASH } from '../../../../../common/constants';
|
||||
|
||||
const getPageData = ($injector) => {
|
||||
const $route = $injector.get('$route');
|
||||
|
@ -67,7 +68,7 @@ uiRoutes
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -13,13 +13,14 @@ import { I18nContext } from 'ui/i18n';
|
|||
import { Listing } from '../../../components/logstash/listing';
|
||||
import { SetupModeRenderer } from '../../../components/renderers';
|
||||
import { LOGSTASH_SYSTEM_ID } from '../../../../../telemetry/common/constants';
|
||||
import { CODE_PATH_LOGSTASH } from '../../../../common/constants';
|
||||
|
||||
uiRoutes.when('/logstash/nodes', {
|
||||
template,
|
||||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -16,6 +16,7 @@ import { timefilter } from 'ui/timefilter';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import { Overview } from '../../../components/logstash/overview';
|
||||
import { MonitoringViewBaseController } from '../../base_controller';
|
||||
import { CODE_PATH_LOGSTASH } from '../../../../common/constants';
|
||||
|
||||
function getPageData($injector) {
|
||||
const $http = $injector.get('$http');
|
||||
|
@ -43,7 +44,7 @@ uiRoutes.when('/logstash', {
|
|||
resolve: {
|
||||
clusters: function (Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -12,7 +12,7 @@ import uiRoutes from'ui/routes';
|
|||
import moment from 'moment';
|
||||
import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
|
||||
import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
|
||||
import { CALCULATE_DURATION_SINCE } from '../../../../common/constants';
|
||||
import { CALCULATE_DURATION_SINCE, CODE_PATH_LOGSTASH } from '../../../../common/constants';
|
||||
import { formatTimestampToDuration } from '../../../../common/format_timestamp_to_duration';
|
||||
import template from './index.html';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
@ -94,7 +94,7 @@ uiRoutes.when('/logstash/pipelines/:id/:hash?', {
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -18,6 +18,7 @@ import { timefilter } from 'ui/timefilter';
|
|||
import { I18nContext } from 'ui/i18n';
|
||||
import { PipelineListing } from '../../../components/logstash/pipeline_listing/pipeline_listing';
|
||||
import { MonitoringViewBaseEuiTableController } from '../..';
|
||||
import { CODE_PATH_LOGSTASH } from '../../../../common/constants';
|
||||
|
||||
/*
|
||||
* Logstash Pipelines Listing page
|
||||
|
@ -61,7 +62,7 @@ uiRoutes
|
|||
resolve: {
|
||||
clusters(Private) {
|
||||
const routeInit = Private(routeInitProvider);
|
||||
return routeInit();
|
||||
return routeInit({ codePaths: [CODE_PATH_LOGSTASH] });
|
||||
},
|
||||
pageData: getPageData
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@ import { NoData } from 'plugins/monitoring/components';
|
|||
import { timefilter } from 'ui/timefilter';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import 'ui/directives/listen';
|
||||
import { CODE_PATH_LICENSE } from '../../../common/constants';
|
||||
|
||||
const REACT_NODE_ID_NO_DATA = 'noDataReact';
|
||||
|
||||
|
@ -91,7 +92,7 @@ export class NoDataController {
|
|||
|
||||
// register the monitoringClusters service.
|
||||
$executor.register({
|
||||
execute: () => monitoringClusters(),
|
||||
execute: () => monitoringClusters(undefined, undefined, [CODE_PATH_LICENSE]),
|
||||
handleResponse: clusters => {
|
||||
if (clusters.length) {
|
||||
model.hasData = true; // use the control flag because we can't redirect from inside here
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import uiRoutes from 'ui/routes';
|
||||
import template from './index.html';
|
||||
import { NoDataController } from './controller';
|
||||
import { CODE_PATH_LICENSE } from '../../../common/constants';
|
||||
uiRoutes
|
||||
.when('/no-data', {
|
||||
template,
|
||||
|
@ -15,7 +16,7 @@ uiRoutes
|
|||
const monitoringClusters = $injector.get('monitoringClusters');
|
||||
const kbnUrl = $injector.get('kbnUrl');
|
||||
|
||||
return monitoringClusters().then(clusters => {
|
||||
return monitoringClusters(undefined, undefined, [CODE_PATH_LICENSE]).then(clusters => {
|
||||
if (clusters && clusters.length) {
|
||||
kbnUrl.changePath('/home');
|
||||
return Promise.reject();
|
||||
|
|
|
@ -17,17 +17,28 @@ import { alertsClustersAggregation } from '../../cluster_alerts/alerts_clusters_
|
|||
import { alertsClusterSearch } from '../../cluster_alerts/alerts_cluster_search';
|
||||
import { checkLicense as checkLicenseForAlerts } from '../../cluster_alerts/check_license';
|
||||
import { getClustersSummary } from './get_clusters_summary';
|
||||
import { CLUSTER_ALERTS_SEARCH_SIZE, STANDALONE_CLUSTER_CLUSTER_UUID } from '../../../common/constants';
|
||||
import {
|
||||
CLUSTER_ALERTS_SEARCH_SIZE,
|
||||
STANDALONE_CLUSTER_CLUSTER_UUID,
|
||||
CODE_PATH_ML,
|
||||
CODE_PATH_ALERTS,
|
||||
CODE_PATH_LOGS,
|
||||
CODE_PATH_KIBANA,
|
||||
CODE_PATH_LOGSTASH,
|
||||
CODE_PATH_BEATS,
|
||||
CODE_PATH_APM
|
||||
} from '../../../common/constants';
|
||||
import { getApmsForClusters } from '../apm/get_apms_for_clusters';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { checkCcrEnabled } from '../elasticsearch/ccr';
|
||||
import { getStandaloneClusterDefinition, hasStandaloneClusters } from '../standalone_clusters';
|
||||
import { getLogTypes } from '../logs';
|
||||
import { isInCodePath } from './is_in_code_path';
|
||||
|
||||
/**
|
||||
* Get all clusters or the cluster associated with {@code clusterUuid} when it is defined.
|
||||
*/
|
||||
export async function getClustersFromRequest(req, indexPatterns, { clusterUuid, start, end } = {}) {
|
||||
export async function getClustersFromRequest(req, indexPatterns, { clusterUuid, start, end, codePaths } = {}) {
|
||||
const {
|
||||
esIndexPattern,
|
||||
kbnIndexPattern,
|
||||
|
@ -76,20 +87,26 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid,
|
|||
const cluster = clusters[0];
|
||||
|
||||
// add ml jobs and alerts data
|
||||
const mlJobs = await getMlJobsForCluster(req, esIndexPattern, cluster);
|
||||
const mlJobs = isInCodePath(codePaths, [CODE_PATH_ML])
|
||||
? await getMlJobsForCluster(req, esIndexPattern, cluster)
|
||||
: null;
|
||||
if (mlJobs !== null) {
|
||||
cluster.ml = { jobs: mlJobs };
|
||||
}
|
||||
const alerts = await alertsClusterSearch(req, alertsIndex, cluster, checkLicenseForAlerts, {
|
||||
start,
|
||||
end,
|
||||
size: CLUSTER_ALERTS_SEARCH_SIZE
|
||||
});
|
||||
const alerts = isInCodePath(codePaths, [CODE_PATH_ALERTS])
|
||||
? await alertsClusterSearch(req, alertsIndex, cluster, checkLicenseForAlerts, {
|
||||
start,
|
||||
end,
|
||||
size: CLUSTER_ALERTS_SEARCH_SIZE
|
||||
})
|
||||
: null;
|
||||
if (alerts) {
|
||||
cluster.alerts = alerts;
|
||||
}
|
||||
|
||||
cluster.logs = await getLogTypes(req, filebeatIndexPattern, { clusterUuid: cluster.cluster_uuid, start, end });
|
||||
cluster.logs = isInCodePath(codePaths, [CODE_PATH_LOGS])
|
||||
? await getLogTypes(req, filebeatIndexPattern, { clusterUuid: cluster.cluster_uuid, start, end })
|
||||
: [];
|
||||
} else if (!isStandaloneCluster) {
|
||||
// get all clusters
|
||||
if (!clusters || clusters.length === 0) {
|
||||
|
@ -103,21 +120,24 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid,
|
|||
clusters = await getSupportedClusters(clusters);
|
||||
|
||||
// add alerts data
|
||||
const clustersAlerts = await alertsClustersAggregation(req, alertsIndex, clusters, checkLicenseForAlerts);
|
||||
clusters.forEach((cluster) => {
|
||||
cluster.alerts = {
|
||||
alertsMeta: {
|
||||
enabled: clustersAlerts.alertsMeta.enabled,
|
||||
message: clustersAlerts.alertsMeta.message // NOTE: this is only defined when the alert feature is disabled
|
||||
},
|
||||
...clustersAlerts[cluster.cluster_uuid]
|
||||
};
|
||||
});
|
||||
if (isInCodePath(codePaths, [CODE_PATH_ALERTS])) {
|
||||
const clustersAlerts = await alertsClustersAggregation(req, alertsIndex, clusters, checkLicenseForAlerts);
|
||||
clusters.forEach((cluster) => {
|
||||
cluster.alerts = {
|
||||
alertsMeta: {
|
||||
enabled: clustersAlerts.alertsMeta.enabled,
|
||||
message: clustersAlerts.alertsMeta.message // NOTE: this is only defined when the alert feature is disabled
|
||||
},
|
||||
...clustersAlerts[cluster.cluster_uuid]
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// add kibana data
|
||||
|
||||
const kibanas = isStandaloneCluster ? [] : await getKibanasForClusters(req, kbnIndexPattern, clusters);
|
||||
const kibanas = isInCodePath(codePaths, [CODE_PATH_KIBANA]) && !isStandaloneCluster
|
||||
? await getKibanasForClusters(req, kbnIndexPattern, clusters)
|
||||
: [];
|
||||
// add the kibana data to each cluster
|
||||
kibanas.forEach(kibana => {
|
||||
const clusterIndex = findIndex(clusters, { cluster_uuid: kibana.clusterUuid });
|
||||
|
@ -125,9 +145,13 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid,
|
|||
});
|
||||
|
||||
// add logstash data
|
||||
const logstashes = await getLogstashForClusters(req, lsIndexPattern, clusters);
|
||||
const logstashes = isInCodePath(codePaths, [CODE_PATH_LOGSTASH])
|
||||
? await getLogstashForClusters(req, lsIndexPattern, clusters)
|
||||
: [];
|
||||
|
||||
const clusterPipelineNodesCount = await getPipelines(req, lsIndexPattern, ['logstash_cluster_pipeline_nodes_count']);
|
||||
const clusterPipelineNodesCount = isInCodePath(codePaths, [CODE_PATH_LOGSTASH])
|
||||
? await getPipelines(req, lsIndexPattern, ['logstash_cluster_pipeline_nodes_count'])
|
||||
: [];
|
||||
|
||||
// add the logstash data to each cluster
|
||||
logstashes.forEach(logstash => {
|
||||
|
@ -142,14 +166,18 @@ export async function getClustersFromRequest(req, indexPatterns, { clusterUuid,
|
|||
});
|
||||
|
||||
// add beats data
|
||||
const beatsByCluster = await getBeatsForClusters(req, beatsIndexPattern, clusters);
|
||||
const beatsByCluster = isInCodePath(codePaths, [CODE_PATH_BEATS])
|
||||
? await getBeatsForClusters(req, beatsIndexPattern, clusters)
|
||||
: [];
|
||||
beatsByCluster.forEach(beats => {
|
||||
const clusterIndex = findIndex(clusters, { cluster_uuid: beats.clusterUuid });
|
||||
set(clusters[clusterIndex], 'beats', beats.stats);
|
||||
});
|
||||
|
||||
// add apm data
|
||||
const apmsByCluster = await getApmsForClusters(req, apmIndexPattern, clusters);
|
||||
const apmsByCluster = isInCodePath(codePaths, [CODE_PATH_APM])
|
||||
? await getApmsForClusters(req, apmIndexPattern, clusters)
|
||||
: [];
|
||||
apmsByCluster.forEach(apm => {
|
||||
const clusterIndex = findIndex(clusters, { cluster_uuid: apm.clusterUuid });
|
||||
set(clusters[clusterIndex], 'apm', apm.stats);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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 { CODE_PATH_ALL } from '../../../common/constants';
|
||||
|
||||
export function isInCodePath(codePaths, codePathsToTest) {
|
||||
if (codePaths.includes(CODE_PATH_ALL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const codePath of codePathsToTest) {
|
||||
if (codePaths.includes(codePath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -29,7 +29,8 @@ export function clusterRoute(server) {
|
|||
timeRange: Joi.object({
|
||||
min: Joi.date().required(),
|
||||
max: Joi.date().required()
|
||||
}).required()
|
||||
}).required(),
|
||||
codePaths: Joi.array().items(Joi.string().required()).required()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -39,6 +40,7 @@ export function clusterRoute(server) {
|
|||
clusterUuid: req.params.clusterUuid,
|
||||
start: req.payload.timeRange.min,
|
||||
end: req.payload.timeRange.max,
|
||||
codePaths: req.payload.codePaths
|
||||
};
|
||||
|
||||
return getClustersFromRequest(req, indexPatterns, options)
|
||||
|
|
|
@ -27,7 +27,8 @@ export function clustersRoute(server) {
|
|||
timeRange: Joi.object({
|
||||
min: Joi.date().required(),
|
||||
max: Joi.date().required()
|
||||
}).required()
|
||||
}).required(),
|
||||
codePaths: Joi.array().items(Joi.string().required()).required()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -40,7 +41,9 @@ export function clustersRoute(server) {
|
|||
try {
|
||||
await verifyMonitoringAuth(req);
|
||||
const indexPatterns = getIndexPatterns(server, { filebeatIndexPattern: INDEX_PATTERN_FILEBEAT });
|
||||
clusters = await getClustersFromRequest(req, indexPatterns);
|
||||
clusters = await getClustersFromRequest(req, indexPatterns, {
|
||||
codePaths: req.payload.codePaths
|
||||
});
|
||||
} catch (err) {
|
||||
throw handleError(err, req);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ export default function ({ getService }) {
|
|||
min: '2017-08-15T21:00:00Z',
|
||||
max: '2017-08-16T00:00:00Z'
|
||||
};
|
||||
const codePaths = ['all'];
|
||||
|
||||
before('load clusters archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
|
@ -31,7 +32,7 @@ export default function ({ getService }) {
|
|||
const { body } = await supertest
|
||||
.post('/api/monitoring/v1/clusters')
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({ timeRange })
|
||||
.send({ timeRange, codePaths })
|
||||
.expect(200);
|
||||
expect(body).to.eql(multiclusterFixture);
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@ export default function ({ getService }) {
|
|||
min: '2017-08-23T21:29:35Z',
|
||||
max: '2017-08-23T21:47:25Z'
|
||||
};
|
||||
const codePaths = ['all'];
|
||||
|
||||
before('load clusters archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
|
@ -34,7 +35,7 @@ export default function ({ getService }) {
|
|||
const { body } = await supertest
|
||||
.post('/api/monitoring/v1/clusters/y1qOsQPiRrGtmdEuM3APJw')
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({ timeRange })
|
||||
.send({ timeRange, codePaths })
|
||||
.expect(200);
|
||||
expect(body).to.eql(overviewFixture);
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ export default function ({ getService }) {
|
|||
min: '2019-03-15T16:19:22.161Z',
|
||||
max: '2019-03-15T17:19:22.161Z'
|
||||
};
|
||||
const codePaths = ['logs'];
|
||||
|
||||
before('load archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
|
@ -30,7 +31,7 @@ export default function ({ getService }) {
|
|||
const { body } = await supertest
|
||||
.post('/api/monitoring/v1/clusters/ZR3ZlJLUTV2V_GlplB83jQ')
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({ timeRange })
|
||||
.send({ timeRange, codePaths })
|
||||
.expect(200);
|
||||
|
||||
expect(body[0].elasticsearch.logs).to.eql(clusterFixture);
|
||||
|
|
|
@ -17,6 +17,7 @@ export default function ({ getService }) {
|
|||
min: '2019-02-04T16:52:11.741Z',
|
||||
max: '2019-02-04T17:52:11.741Z'
|
||||
};
|
||||
const codePaths = ['all'];
|
||||
|
||||
before('load archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
|
@ -30,7 +31,7 @@ export default function ({ getService }) {
|
|||
const { body } = await supertest
|
||||
.post('/api/monitoring/v1/clusters/__standalone_cluster__')
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({ timeRange })
|
||||
.send({ timeRange, codePaths })
|
||||
.expect(200);
|
||||
|
||||
expect(body).to.eql(clusterFixture);
|
||||
|
|
|
@ -20,6 +20,7 @@ export default function ({ getService }) {
|
|||
min: '2019-02-04T16:52:11.741Z',
|
||||
max: '2019-02-04T17:52:11.741Z'
|
||||
};
|
||||
const codePaths = ['all'];
|
||||
|
||||
before('load archive', () => {
|
||||
return esArchiver.load(archive);
|
||||
|
@ -33,7 +34,7 @@ export default function ({ getService }) {
|
|||
const { body } = await supertest
|
||||
.post('/api/monitoring/v1/clusters')
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
.send({ timeRange })
|
||||
.send({ timeRange, codePaths })
|
||||
.expect(200);
|
||||
expect(body).to.eql(clustersFixture);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue