Skip to content

Commit

Permalink
Passing global state ccs
Browse files Browse the repository at this point in the history
  • Loading branch information
igoristic committed Oct 8, 2020
1 parent 4751894 commit 8856761
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
6 changes: 4 additions & 2 deletions x-pack/plugins/monitoring/public/services/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ export function monitoringClustersProvider($injector) {
if (Legacy.shims.isCloud) {
return Promise.resolve();
}
const ccs = window.location.hash.split('?')[0] === '#/home' ? 'ccs' : 'single';
const globalState = $injector.get('globalState');
return $http
.get(`../api/monitoring/v1/elasticsearch_settings/check/internal_monitoring/${ccs}`)
.post('../api/monitoring/v1/elasticsearch_settings/check/internal_monitoring', {
ccs: globalState.ccs,
})
.then(({ data }) => {
showInternalMonitoringToast({
legacyIndices: data.legacy_indices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export function internalMonitoringCheckRoute(
server: { config: () => unknown },
npRoute: RouteDependencies
) {
npRoute.router.get(
npRoute.router.post(
{
path: '/api/monitoring/v1/elasticsearch_settings/check/internal_monitoring/{ccs}',
path: '/api/monitoring/v1/elasticsearch_settings/check/internal_monitoring',
validate: {
params: schema.object({
body: schema.object({
ccs: schema.maybe(schema.string()),
}),
},
Expand All @@ -89,17 +89,10 @@ export function internalMonitoringCheckRoute(
};

const config = server.config();
const { ccs } = request.params;
const ccsPrefix = ccs === 'ccs' ? '*' : null;
const esIndexPattern = prefixIndexPattern(
config,
INDEX_PATTERN_ELASTICSEARCH,
ccsPrefix,
true
);
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccsPrefix, true);
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccsPrefix, true);

const { ccs } = request.body;
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs, true);
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs, true);
const lsIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_LOGSTASH, ccs, true);
const indexCounts = await Promise.all([
checkLatestMonitoringIsLegacy(context, esIndexPattern),
checkLatestMonitoringIsLegacy(context, kbnIndexPattern),
Expand Down

0 comments on commit 8856761

Please sign in to comment.