-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Changes from 8 commits
978c636
df51458
6750d52
654e485
6ef83f1
8797eab
4582b2a
cbb0fb4
d6b31c2
b9e7db8
28f4093
57cbbfc
a3171f9
2c45f1c
60daec3
ddbdad0
2216464
24f8817
c44908f
9c7d7b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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: number; | ||
metricbeatIndices: number; | ||
} | ||
|
||
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 "Legacy Collection" for Stack Monitoring. | ||
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 Legacy Monitoring Detected" | ||
/> | ||
), | ||
text: toMountPoint( | ||
<div> | ||
<p> | ||
{i18n.translate('xpack.monitoring.internalAndMetricbeatMonitoringToast.description', { | ||
defaultMessage: `It appears you are using both Metricbeat and "Legacy Collection" for Stack Monitoring. | ||
only Metricbeat type monitoring will be supported in the next major release (8.0.0). | ||
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`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love it! |
||
external | ||
target="_blank" | ||
> | ||
{learnMoreLabel()} | ||
</EuiLink> | ||
</div> | ||
), | ||
}); | ||
}; | ||
|
||
export const showInternalMonitoringToast = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's less invasive. Also I feel like |
||
legacyIndices, | ||
metricbeatIndices, | ||
}: MonitoringIndicesTypes) => { | ||
if (isInSetupMode()) { | ||
return; | ||
} | ||
|
||
if (legacyIndices && !metricbeatIndices) { | ||
showIfLegacyOnlyIndices(); | ||
} else if (legacyIndices && metricbeatIndices) { | ||
showIfLegacyAndMetricbeatIndices(); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// @ts-ignore | ||
import { RequestHandlerContext } from 'kibana/server'; | ||
import { getIndexPatterns } from '../../../../../lib/cluster/get_index_patterns'; | ||
|
||
// @ts-ignore | ||
import { handleError } from '../../../../../lib/errors'; | ||
import { RouteDependencies } from '../../../../../types'; | ||
|
||
const queryBody = { | ||
size: 15, | ||
igoristic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
query: { | ||
bool: { | ||
filter: [ | ||
{ | ||
range: { | ||
timestamp: { | ||
gte: 'now-15m', | ||
igoristic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lte: 'now', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
sort: [ | ||
{ | ||
timestamp: { | ||
order: 'desc', | ||
}, | ||
}, | ||
], | ||
_source: { | ||
excludes: ['*'], | ||
}, | ||
}; | ||
|
||
const checkLatestMonitoringIsLegacy = async (context: RequestHandlerContext, index: string) => { | ||
const { client: esClient } = context.core.elasticsearch.legacy; | ||
const result = await esClient.callAsCurrentUser('search', { | ||
index, | ||
body: queryBody, | ||
}); | ||
|
||
const { | ||
hits: { hits }, | ||
} = result; | ||
const counts = { | ||
legacyIndicesCount: 0, | ||
mbIndicesCount: 0, | ||
}; | ||
|
||
if (!hits?.length) { | ||
return counts; | ||
} | ||
|
||
counts.mbIndicesCount = hits.filter(({ _index }: { _index: string }) => | ||
_index.includes('-mb-') | ||
).length; | ||
|
||
counts.legacyIndicesCount = hits.length - counts.mbIndicesCount; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These counts seem off to me. I added this debug code: which results in:
Maybe you can just do a query like:
|
||
|
||
return counts; | ||
}; | ||
|
||
export function internalMonitoringCheckRoute(server: unknown, npRoute: RouteDependencies) { | ||
npRoute.router.get( | ||
{ | ||
path: '/api/monitoring/v1/elasticsearch_settings/check/internal_monitoring', | ||
validate: false, | ||
}, | ||
async (context, _request, response) => { | ||
try { | ||
const typeCount = { | ||
legacy_indices: 0, | ||
mb_indices: 0, | ||
}; | ||
|
||
const { esIndexPattern, kbnIndexPattern, lsIndexPattern } = getIndexPatterns(server); | ||
const indexCounts = await Promise.all([ | ||
checkLatestMonitoringIsLegacy(context, esIndexPattern), | ||
checkLatestMonitoringIsLegacy(context, kbnIndexPattern), | ||
checkLatestMonitoringIsLegacy(context, lsIndexPattern), | ||
]); | ||
|
||
indexCounts.forEach((counts) => { | ||
typeCount.legacy_indices += counts.legacyIndicesCount; | ||
typeCount.mb_indices += counts.mbIndicesCount; | ||
}); | ||
|
||
return response.ok({ | ||
body: typeCount, | ||
}); | ||
} catch (err) { | ||
throw handleError(err); | ||
} | ||
} | ||
); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.