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] "Internal Monitoring" deprecation warning #72020

Merged
merged 20 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
978c636
Internal Monitoring deprecation
igoristic Jul 16, 2020
df51458
Fixed type
igoristic Jul 16, 2020
6750d52
Added if cloud logic
igoristic Jul 16, 2020
654e485
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 16, 2020
6ef83f1
Fixed i18n test
igoristic Jul 16, 2020
8797eab
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 20, 2020
4582b2a
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 20, 2020
cbb0fb4
Addressed code review feedback
igoristic Jul 20, 2020
d6b31c2
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 21, 2020
b9e7db8
Fixed types
igoristic Jul 21, 2020
28f4093
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 21, 2020
57cbbfc
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 21, 2020
a3171f9
Changed query
igoristic Jul 21, 2020
2c45f1c
Merge branch 'master' into internal-monitoring-deprecation
elasticmachine Jul 21, 2020
60daec3
Merge branch 'master' into internal-monitoring-deprecation
elasticmachine Jul 22, 2020
ddbdad0
Merge branch 'master' into internal-monitoring-deprecation
elasticmachine Jul 22, 2020
2216464
Added delay to fix a test
igoristic Jul 23, 2020
24f8817
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic Jul 27, 2020
c44908f
Fixed tests
igoristic Jul 27, 2020
9c7d7b7
Fixed text
igoristic Jul 27, 2020
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
123 changes: 123 additions & 0 deletions x-pack/plugins/monitoring/public/lib/internal_monitoring_toasts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* 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 React from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiLink } from '@elastic/eui';
import { Legacy } from '../legacy_shims';
import { toMountPoint } from '../../../../../src/plugins/kibana_react/public';
import { isInSetupMode, toggleSetupMode } from './setup_mode';

export interface MonitoringIndicesTypes {
legacyIndices: boolean;
metricbeatIndices: boolean;
}

const enterSetupModeLabel = () =>
i18n.translate('xpack.monitoring.internalMonitoringToast.enterSetupMode', {
defaultMessage: 'Enter setup mode',
});

const learnMoreLabel = () =>
i18n.translate('xpack.monitoring.internalMonitoringToast.learnMoreAction', {
defaultMessage: 'Learn more',
});

const showIfLegacyOnlyIndices = () => {
const { ELASTIC_WEBSITE_URL } = Legacy.shims.docLinks;
const toast = Legacy.shims.toastNotifications.addWarning({
title: toMountPoint(
<FormattedMessage
id="xpack.monitoring.internalMonitoringToast.title"
defaultMessage="Internal Monitoring Detected"
/>
),
text: toMountPoint(
<div>
<p>
{i18n.translate('xpack.monitoring.internalMonitoringToast.description', {
defaultMessage: `It appears you are using "Internal Collection" for Stack Monitoring.
igoristic marked this conversation as resolved.
Show resolved Hide resolved
This method of monitoring will no longer be supported in the next major release (8.0.0).
Please follow the steps in setup mode to start monitoring with Metricbeat.`,
})}
</p>
<EuiLink
onClick={() => {
Legacy.shims.toastNotifications.remove(toast);
toggleSetupMode(true);
}}
>
{enterSetupModeLabel()}
</EuiLink>

<EuiSpacer />
<EuiLink
href={`${ELASTIC_WEBSITE_URL}blog/external-collection-for-elastic-stack-monitoring-is-now-available-via-metricbeat`}
external
target="_blank"
>
{learnMoreLabel()}
</EuiLink>
</div>
),
});
};

const showIfLegacyAndMetricbeatIndices = () => {
const { ELASTIC_WEBSITE_URL } = Legacy.shims.docLinks;
const toast = Legacy.shims.toastNotifications.addWarning({
title: toMountPoint(
<FormattedMessage
id="xpack.monitoring.internalAndMetricbeatMonitoringToast.title"
defaultMessage="Partial Internal Monitoring Detected"
igoristic marked this conversation as resolved.
Show resolved Hide resolved
/>
),
text: toMountPoint(
<div>
<p>
{i18n.translate('xpack.monitoring.internalAndMetricbeatMonitoringToast.description', {
defaultMessage: `It appears you are using both Metricbeat and "Internal Collection" for Stack Monitoring.
igoristic marked this conversation as resolved.
Show resolved Hide resolved
only Metricbeat type monitoring will be supported in the next major release (8.0.0).
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we said: Monitoring will require Metricbeat collection in the next major version (8.0.0).

or maybe @gchaps can help here

Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

In 8.0.0, you must use Metricbeat to collect monitoring data.

Please follow the steps in setup mode to migrate the rest of the monitoring to Metricbeat.`,
})}
</p>
<EuiLink
onClick={() => {
Legacy.shims.toastNotifications.remove(toast);
toggleSetupMode(true);
}}
>
{enterSetupModeLabel()}
</EuiLink>

<EuiSpacer />
<EuiLink
href={`${ELASTIC_WEBSITE_URL}blog/external-collection-for-elastic-stack-monitoring-is-now-available-via-metricbeat`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Love it!

external
target="_blank"
>
{learnMoreLabel()}
</EuiLink>
</div>
),
});
};

export const showInternalMonitoringToast = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why did you decide to go with a toast instead of a EuiCallout at the top of the page?

Copy link
Contributor Author

@igoristic igoristic Jul 20, 2020

Choose a reason for hiding this comment

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

I think it's less invasive. Also I feel like EuiCallout is too close to the enter setup button which makes it appear as if they're somehow associated.

legacyIndices,
metricbeatIndices,
}: MonitoringIndicesTypes) => {
if (isInSetupMode()) {
return;
}

if (legacyIndices && !metricbeatIndices) {
showIfLegacyOnlyIndices();
} else if (legacyIndices && metricbeatIndices) {
showIfLegacyAndMetricbeatIndices();
}
};
23 changes: 22 additions & 1 deletion x-pack/plugins/monitoring/public/services/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { ajaxErrorHandlersProvider } from '../lib/ajax_error_handler';
import { Legacy } from '../legacy_shims';
import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../common/constants';
import { showInternalMonitoringToast } from '../lib/internal_monitoring_toasts';

function formatClusters(clusters) {
return clusters.map(formatCluster);
Expand Down Expand Up @@ -62,10 +63,30 @@ export function monitoringClustersProvider($injector) {
});
}

function ensureMetricbeatEnabled() {
if (Legacy.shims.isCloud) {
return Promise.resolve();
}

return $http
.get('../api/monitoring/v1/elasticsearch_settings/check/internal_monitoring')
.then(({ data }) => {
showInternalMonitoringToast({
legacyIndices: data.legacy_indices,
metricbeatIndices: data.mb_indices,
});
})
.catch((err) => {
const Private = $injector.get('Private');
const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider);
return ajaxErrorHandlers(err);
});
}

if (!once) {
return getClusters().then((clusters) => {
if (clusters.length) {
return ensureAlertsEnabled()
return Promise.all([ensureAlertsEnabled(), ensureMetricbeatEnabled()])
.then(() => {
once = true;
return clusters;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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 { CatIndicesParams } from 'elasticsearch';
// @ts-ignore
import { handleError } from '../../../../../lib/errors';
import { RouteDependencies } from '../../../../../types';

export function internalMonitoringCheckRoute(_server: unknown, npRoute: RouteDependencies) {
npRoute.router.get(
{
path: '/api/monitoring/v1/elasticsearch_settings/check/internal_monitoring',
options: { tags: ['access:monitoring'] },
igoristic marked this conversation as resolved.
Show resolved Hide resolved
validate: false,
},
async (context, _request, response) => {
try {
const catQuery: Pick<CatIndicesParams, 'format' | 'h'> & {
expand_wildcards: string;
index?: string;
} = {
format: 'json',
h: 'index',
expand_wildcards: 'hidden,all',
index: '.monitoring-*',
};

const { client: esClient } = context.core.elasticsearch.legacy;
const monitoringIndices = await esClient.callAsInternalUser('transport.request', {
igoristic marked this conversation as resolved.
Show resolved Hide resolved
method: 'GET',
path: '/_cat/indices',
igoristic marked this conversation as resolved.
Show resolved Hide resolved
query: catQuery,
});

const mbIndices = monitoringIndices.filter(({ index }: { index: string }) =>
index.includes('-mb-')
);

return response.ok({
body: {
legacy_indices: Boolean(monitoringIndices.length - mbIndices.length),
mb_indices: Boolean(mbIndices.length),
},
});
} catch (err) {
throw handleError(err);
}
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { internalMonitoringCheckRoute } from './check/internal_monitoring';
export { clusterSettingsCheckRoute } from './check/cluster';
export { nodesSettingsCheckRoute } from './check/nodes';
export { setCollectionEnabledRoute } from './set/collection_enabled';
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/server/routes/api/v1/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export {
ccrShardRoute,
} from './elasticsearch';
export {
internalMonitoringCheckRoute,
clusterSettingsCheckRoute,
nodesSettingsCheckRoute,
setCollectionEnabledRoute,
Expand Down