Remove dependency on infra in monitoring plugin (#203551)

Blocked by https://github.com/elastic/kibana/pull/203492

The monitoring plugin is currently marked as observability plugin
because it's relying on the `infra` plugin.

However, in practice, no functionality is actually used. This PR removes
the dependency -it makes monitoring and logstash a `platform/private`
plugin as well (logstash needs to go along with monitoring, but that
should be fine because it's only required by monitoring).

Some considerations left as comments in the code.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Joe Reuter 2024-12-11 17:11:06 +01:00 committed by GitHub
parent 0b9179acbd
commit 59d3ac65ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 28 additions and 34 deletions

View file

@ -4,7 +4,7 @@
"owner": [
"@elastic/logstash"
],
"group": "observability",
"group": "platform",
"visibility": "private",
"plugin": {
"id": "logstash",

View file

@ -4,7 +4,7 @@
"owner": [
"@elastic/stack-monitoring"
],
"group": "observability",
"group": "platform",
"visibility": "private",
"plugin": {
"id": "monitoring",
@ -23,7 +23,6 @@
"share"
],
"optionalPlugins": [
"infra",
"usageCollection",
"home",
"cloud",

View file

@ -12,7 +12,9 @@ exports[`Logs should render a link to filter by cluster uuid 1`] = `
id="xpack.monitoring.logs.listing.linkText"
values={
Object {
"link": <EuiLink>
"link": <EuiLink
href="http://localhost:5601/app/discover"
>
Discover
</EuiLink>,
}
@ -34,7 +36,9 @@ exports[`Logs should render a link to filter by cluster uuid and index uuid 1`]
id="xpack.monitoring.logs.listing.linkText"
values={
Object {
"link": <EuiLink>
"link": <EuiLink
href="http://localhost:5601/app/discover"
>
Discover
</EuiLink>,
}
@ -56,7 +60,9 @@ exports[`Logs should render a link to filter by cluster uuid and node uuid 1`] =
id="xpack.monitoring.logs.listing.linkText"
values={
Object {
"link": <EuiLink>
"link": <EuiLink
href="http://localhost:5601/app/discover"
>
Discover
</EuiLink>,
}
@ -284,7 +290,9 @@ exports[`Logs should render normally 1`] = `
id="xpack.monitoring.logs.listing.linkText"
values={
Object {
"link": <EuiLink>
"link": <EuiLink
href="http://localhost:5601/app/discover"
>
Discover
</EuiLink>,
}

View file

@ -111,7 +111,7 @@ const clusterColumns = [
},
];
function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) {
function getDiscoverLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) {
const params = [];
if (clusterUuid) {
params.push(`elasticsearch.cluster.uuid:${clusterUuid}`);
@ -126,6 +126,10 @@ function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices)
const filter = params.join(' and ');
const discoverLocator = sharePlugin.url.locators.get('DISCOVER_APP_LOCATOR');
if (!discoverLocator) {
return;
}
const base = discoverLocator.getRedirectUrl({
dataViewSpec: {
id: logsIndices,
@ -175,7 +179,7 @@ export class LogsContent extends PureComponent {
}
renderCallout() {
const { capabilities: uiCapabilities, infra, kibanaServices } = Legacy.shims;
const { capabilities: uiCapabilities, kibanaServices } = Legacy.shims;
const show = uiCapabilities.discover && uiCapabilities.discover.show;
const {
@ -190,8 +194,9 @@ export class LogsContent extends PureComponent {
if (!enabled || !show) {
return null;
}
const discoverLink = getDiscoverLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices);
return infra ? (
return discoverLink ? (
<EuiCallOut
size="m"
title={i18n.translate('xpack.monitoring.logs.listing.calloutTitle', {
@ -205,9 +210,7 @@ export class LogsContent extends PureComponent {
defaultMessage="Visit {link} to dive deeper."
values={{
link: (
<EuiLink
href={getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices)}
>
<EuiLink href={discoverLink}>
{i18n.translate('xpack.monitoring.logs.listing.calloutLinkText', {
defaultMessage: 'Discover',
})}

View file

@ -15,7 +15,6 @@ jest.mock('../../legacy_shims', () => ({
shims: {
getBasePath: () => '',
capabilities: { discover: { show: true } },
infra: {},
},
},
}));
@ -24,7 +23,9 @@ const sharePlugin = {
url: {
locators: {
get: () => {
return sharePluginMock.createLocator();
const locatorMock = sharePluginMock.createLocator();
locatorMock.getRedirectUrl.mockReturnValue('http://localhost:5601/app/discover');
return locatorMock;
},
},
},

View file

@ -22,7 +22,6 @@ import { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-
import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry';
import { ActionTypeModel, RuleTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types';
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
import {
MonitoringStartPluginDependencies,
LegacyMonitoringStartPluginDependencies,
@ -74,7 +73,6 @@ export interface IShims {
usageCollection: UsageCollectionSetup;
kibanaServices: CoreStart & { usageCollection: UsageCollectionSetup };
appMountParameters: AppMountParameters;
infra?: InfraClientStartExports;
}
export class Legacy {
@ -87,7 +85,6 @@ export class Legacy {
triggersActionsUi,
usageCollection,
appMountParameters,
infra,
}: LegacyMonitoringStartPluginDependencies) {
this._shims = {
toastNotifications: core.notifications.toasts,
@ -146,7 +143,6 @@ export class Legacy {
usageCollection,
},
appMountParameters,
infra,
};
}

View file

@ -111,7 +111,6 @@ export class MonitoringPlugin
usageCollection: plugins.usageCollection,
appMountParameters: params,
dataViews: pluginsStart.dataViews,
infra: pluginsStart.infra,
};
Legacy.init({
@ -126,7 +125,6 @@ export class MonitoringPlugin
usageCollection: deps.usageCollection,
appMountParameters: deps.appMountParameters,
dataViews: deps.dataViews,
infra: deps.infra,
share: deps.share,
});

View file

@ -15,7 +15,6 @@ export type { MLJobs } from '../server/lib/elasticsearch/get_ml_jobs';
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { DashboardStart } from '@kbn/dashboard-plugin/public';
import { FleetStart } from '@kbn/fleet-plugin/public';
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';
import { ReactNode } from 'react';
@ -27,7 +26,6 @@ export interface MonitoringStartPluginDependencies {
dataViews: DataViewsPublicPluginStart;
dashboard?: DashboardStart;
fleet?: FleetStart;
infra?: InfraClientStartExports;
share: SharePluginStart;
}

View file

@ -6,7 +6,6 @@
*/
import { featuresPluginMock } from '@kbn/features-plugin/server/mocks';
import { infraPluginMock } from '@kbn/infra-plugin/server/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/server/mocks';
import { configSchema, createConfig } from '../../../config';
@ -37,7 +36,6 @@ const mockReq = (
plugins: {
usageCollection: usageCollectionSetup,
features: featuresPluginMock.createSetup(),
infra: infraPluginMock.createSetupContract(),
},
},
},

View file

@ -26,7 +26,6 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen
async (context, request, response) => {
try {
const alertingContext = await context.alerting;
const infraContext = await context.infra;
const actionContext = await context.actions;
const alerts = RulesFactory.getAll();
@ -39,7 +38,7 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen
if (!isSufficientlySecure || !hasPermanentEncryptionKey) {
server.log.info(
`Skipping rule creation for "${infraContext.spaceId}" space; Stack Monitoring rules require API keys to be enabled and an encryption key to be configured.`
`Skipping rule creation; Stack Monitoring rules require API keys to be enabled and an encryption key to be configured.`
);
return response.ok({
body: {
@ -90,9 +89,7 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen
alerts.map((alert) => alert.createIfDoesNotExist(rulesClient, actionsClient, actions))
);
server.log.info(
`Created ${createdAlerts.length} alerts for "${infraContext.spaceId}" space`
);
server.log.info(`Created ${createdAlerts.length} alerts`);
return response.ok({ body: { createdAlerts } });
} catch (err) {

View file

@ -25,7 +25,6 @@ import type {
import type { AlertingApiRequestHandlerContext } from '@kbn/alerting-plugin/server';
import type { RacApiRequestHandlerContext } from '@kbn/rule-registry-plugin/server';
import { AlertingServerSetup, AlertingServerStart } from '@kbn/alerting-plugin/server';
import { InfraPluginSetup, InfraRequestHandlerContext } from '@kbn/infra-plugin/server';
import { LicensingPluginStart } from '@kbn/licensing-plugin/server';
import { FeaturesPluginSetup } from '@kbn/features-plugin/server';
import { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server';
@ -51,14 +50,12 @@ export interface PluginsSetup {
usageCollection?: UsageCollectionSetup;
features: FeaturesPluginSetup;
alerting?: AlertingServerSetup;
infra: InfraPluginSetup;
cloud?: CloudSetup;
}
export type RequestHandlerContextMonitoringPlugin = CustomRequestHandlerContext<{
actions?: ActionsApiRequestHandlerContext;
alerting?: AlertingApiRequestHandlerContext;
infra: InfraRequestHandlerContext;
ruleRegistry?: RacApiRequestHandlerContext;
}>;

View file

@ -17,7 +17,6 @@
"@kbn/cloud-plugin",
"@kbn/encrypted-saved-objects-plugin",
"@kbn/features-plugin",
"@kbn/infra-plugin",
"@kbn/licensing-plugin",
"@kbn/triggers-actions-ui-plugin",
"@kbn/expect",