[Infra] Disable infra plugin in serverless projects (#165289)

closes https://github.com/elastic/kibana/issues/158925

## Summary

This PR disables the infra plugin in the `oblt` and `security` projects

### Oblt
**Navbar**
<img width="300" alt="image"
src="f88fd2a5-ed58-4bcf-b5ad-5b25357daf5c">

**Saved Objects**
<img width="800" alt="image"
src="4140760c-2572-4391-8977-bc97fcd14bb8">



**Server-side APIs**
<img width="800" alt="image"
src="eb22b024-dfd5-4c7f-b760-bfd2c633f759">

**Infra routes**
/metrics/inventory

<img width="500" alt="image"
src="6ddba766-c6f0-40d0-9183-2bcbae348d52">

**Alert rules**
<img width="300" alt="image"
src="d03d087e-d562-425b-a4d9-a17d5fe0b158">


### APM

Infra links hidden in the Transaction "Investigate" pop up menu
<img width="800" alt="image"
src="d9364d55-6e06-4ac0-8668-6ce2331a6250">

Infra links removed from Services Overview Instance actions
<img width="800" alt="image"
src="73410e5c-be6c-4174-8df0-76fb6a25b2f6">

** Server Routes **

<img width="800" alt="image"
src="488f639b-81e8-497d-a55e-4e7f31644bc5">

<img width="800" alt="image"
src="4366005a-2eb8-4f33-8d1e-09865cad06b4">

<img width="800" alt="image"
src="46b34d0d-8171-4d8d-bfb8-fd4c32583fbb">





### Security

**Saved Objects**
<img width="800" alt="image"
src="14f08e7e-565b-42e9-8fc4-753d1b54c14a">



**Server-side APIs**
<img width="800" alt="image"
src="eb22b024-dfd5-4c7f-b760-bfd2c633f759">

**Infra routes**
/metrics/inventory

<img width="500" alt="image"
src="6ddba766-c6f0-40d0-9183-2bcbae348d52">


### How to test

- Start a local ES instance
- run `yarn serverless-oblt` and `yarn serverless-security`
- Validate the screenshots above.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Carlos Crespo 2023-09-08 15:05:28 +02:00 committed by GitHub
parent 631ffbb9a5
commit 7ba355483f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 220 additions and 195 deletions

View file

@ -3,6 +3,7 @@
## Disable plugins
enterpriseSearch.enabled: false
xpack.cloudSecurityPosture.enabled: false
xpack.infra.enabled: false
xpack.securitySolution.enabled: false
xpack.uptime.enabled: false
xpack.legacy_uptime.enabled: false

View file

@ -3,6 +3,7 @@
## Disable plugins
enterpriseSearch.enabled: false
xpack.apm.enabled: false
xpack.infra.enabled: false
xpack.observability.enabled: false
xpack.uptime.enabled: false
xpack.legacy_uptime.enabled: false

View file

@ -15,7 +15,6 @@
"controls",
"embeddable",
"features",
"infra",
"logsShared",
"inspector",
"licensing",
@ -41,6 +40,7 @@
"discover",
"fleet",
"fieldFormats",
"infra",
"home",
"ml",
"security",
@ -49,7 +49,7 @@
"usageCollection",
"customIntegrations", // Move this to requiredPlugins after completely migrating from the Tutorials Home App
"licenseManagement",
"profiling",
"profiling"
],
"requiredBundles": [
"advancedSettings",

View file

@ -40,10 +40,7 @@ export function InstanceActionsMenu({
kuery,
onClose,
}: Props) {
const {
core,
infra: { locators },
} = useApmPluginContext();
const { core, infra } = useApmPluginContext();
const { data, status } = useInstanceDetailsFetcher({
serviceName,
serviceNodeName,
@ -92,7 +89,7 @@ export function InstanceActionsMenu({
basePath: core.http.basePath,
onFilterByInstanceClick: handleFilterByInstanceClick,
metricsHref,
infraLocators: locators,
infraLocators: infra?.locators,
});
return (

View file

@ -52,67 +52,71 @@ export function getMenuSections({
? new Date(instanceDetails['@timestamp']).valueOf()
: undefined;
const infraMetricsQuery = getInfraMetricsQuery(instanceDetails['@timestamp']);
const infraNodeLocator = infraLocators.nodeLogsLocator;
const infraNodeLocator = infraLocators?.nodeLogsLocator;
const podActions: Action[] = [
{
key: 'podLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podLogs',
{ defaultMessage: 'Pod logs' }
),
href: infraNodeLocator.getRedirectUrl({
nodeId: podId!,
nodeType: 'pod',
time,
}),
condition: !!podId,
},
{
key: 'podMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podMetrics',
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery,
}),
condition: !!podId,
},
];
const podActions: Action[] = infraNodeLocator
? [
{
key: 'podLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podLogs',
{ defaultMessage: 'Pod logs' }
),
href: infraNodeLocator?.getRedirectUrl({
nodeId: podId!,
nodeType: 'pod',
time,
}),
condition: !!podId,
},
{
key: 'podMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podMetrics',
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery,
}),
condition: !!podId,
},
]
: [];
const containerActions: Action[] = [
{
key: 'containerLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerLogs',
{ defaultMessage: 'Container logs' }
),
href: infraNodeLocator.getRedirectUrl({
nodeId: containerId!,
nodeType: 'container',
time,
}),
condition: !!containerId,
},
{
key: 'containerMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerMetrics',
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery,
}),
condition: !!containerId,
},
];
const containerActions: Action[] = infraNodeLocator
? [
{
key: 'containerLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerLogs',
{ defaultMessage: 'Container logs' }
),
href: infraNodeLocator?.getRedirectUrl({
nodeId: containerId!,
nodeType: 'container',
time,
}),
condition: !!containerId,
},
{
key: 'containerMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerMetrics',
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery,
}),
condition: !!containerId,
},
]
: [];
const apmActions: Action[] = [
{

View file

@ -49,7 +49,7 @@ export const getSections = ({
basePath: IBasePath;
location: Location;
apmRouter: ApmRouter;
infraLocators: InfraLocators;
infraLocators?: InfraLocators;
infraLinksAvailable: boolean;
profilingLocators?: ProfilingLocators;
rangeFrom: string;
@ -60,7 +60,7 @@ export const getSections = ({
const hostName = transaction.host?.hostname;
const podId = transaction.kubernetes?.pod?.uid;
const containerId = transaction.container?.id;
const { nodeLogsLocator, logsLocator } = infraLocators;
const { nodeLogsLocator, logsLocator } = infraLocators ?? {};
const time = Math.round(transaction.timestamp.us / 1000);
const infraMetricsQuery = getInfraMetricsQuery(transaction);
@ -79,94 +79,102 @@ export const getSections = ({
)}`,
});
const podActions: Action[] = [
{
key: 'podLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showPodLogsLinkLabel',
{ defaultMessage: 'Pod logs' }
),
href: nodeLogsLocator.getRedirectUrl({
nodeId: podId!,
nodeType: 'pod',
time,
}),
condition: !!podId,
},
{
key: 'podMetrics',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showPodMetricsLinkLabel',
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery,
}),
condition: !!podId,
},
];
const podActions: Action[] = nodeLogsLocator
? [
{
key: 'podLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showPodLogsLinkLabel',
{ defaultMessage: 'Pod logs' }
),
href: nodeLogsLocator.getRedirectUrl({
nodeId: podId!,
nodeType: 'pod',
time,
}),
condition: !!podId,
},
{
key: 'podMetrics',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showPodMetricsLinkLabel',
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery,
}),
condition: !!podId,
},
]
: [];
const containerActions: Action[] = [
{
key: 'containerLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showContainerLogsLinkLabel',
{ defaultMessage: 'Container logs' }
),
href: nodeLogsLocator.getRedirectUrl({
nodeId: containerId!,
nodeType: 'container',
time,
}),
condition: !!containerId,
},
{
key: 'containerMetrics',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showContainerMetricsLinkLabel',
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery,
}),
condition: !!containerId,
},
];
const containerActions: Action[] = nodeLogsLocator
? [
{
key: 'containerLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showContainerLogsLinkLabel',
{ defaultMessage: 'Container logs' }
),
href: nodeLogsLocator.getRedirectUrl({
nodeId: containerId!,
nodeType: 'container',
time,
}),
condition: !!containerId,
},
{
key: 'containerMetrics',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showContainerMetricsLinkLabel',
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery,
}),
condition: !!containerId,
},
]
: [];
const hostActions: Action[] = [
{
key: 'hostLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showHostLogsLinkLabel',
{ defaultMessage: 'Host logs' }
),
href: nodeLogsLocator.getRedirectUrl({
nodeId: hostName!,
nodeType: 'host',
time,
}),
condition: !!hostName,
},
{
key: 'hostMetrics',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showHostMetricsLinkLabel',
{ defaultMessage: 'Host metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/host-detail/${hostName}`,
query: infraMetricsQuery,
}),
condition: !!hostName,
},
...(nodeLogsLocator
? [
{
key: 'hostLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showHostLogsLinkLabel',
{ defaultMessage: 'Host logs' }
),
href: nodeLogsLocator.getRedirectUrl({
nodeId: hostName!,
nodeType: 'host',
time,
}),
condition: !!hostName,
},
{
key: 'hostMetrics',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showHostMetricsLinkLabel',
{ defaultMessage: 'Host metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/host-detail/${hostName}`,
query: infraMetricsQuery,
}),
condition: !!hostName,
},
]
: []),
{
key: 'hostProfilingFlamegraph',
label: i18n.translate(
@ -205,20 +213,22 @@ export const getSections = ({
},
];
const logActions: Action[] = [
{
key: 'traceLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showTraceLogsLinkLabel',
{ defaultMessage: 'Trace logs' }
),
href: logsLocator.getRedirectUrl({
filter: `trace.id:"${transaction.trace.id}" OR (not trace.id:* AND "${transaction.trace.id}")`,
time,
}),
condition: true,
},
];
const logActions: Action[] = logsLocator
? [
{
key: 'traceLogs',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showTraceLogsLinkLabel',
{ defaultMessage: 'Trace logs' }
),
href: logsLocator.getRedirectUrl({
filter: `trace.id:"${transaction.trace.id}" OR (not trace.id:* AND "${transaction.trace.id}")`,
time,
}),
condition: true,
},
]
: [];
const uptimeActions: Action[] = [
{
@ -273,7 +283,7 @@ export const getSections = ({
const sectionRecord: SectionRecord = {
observability: [
...(infraLinksAvailable
...(infraLinksAvailable && infraLocators
? [
{
key: 'podDetails',
@ -329,19 +339,26 @@ export const getSections = ({
]
: []),
{
key: 'traceDetails',
title: i18n.translate('xpack.apm.transactionActionMenu.trace.title', {
defaultMessage: 'Trace details',
}),
subtitle: i18n.translate(
'xpack.apm.transactionActionMenu.trace.subtitle',
{
defaultMessage: 'View trace logs to get further details.',
}
),
actions: logActions,
},
...(infraLocators
? [
{
key: 'traceDetails',
title: i18n.translate(
'xpack.apm.transactionActionMenu.trace.title',
{
defaultMessage: 'Trace details',
}
),
subtitle: i18n.translate(
'xpack.apm.transactionActionMenu.trace.subtitle',
{
defaultMessage: 'View trace logs to get further details.',
}
),
actions: logActions,
},
]
: []),
{
key: 'statusDetails',
title: i18n.translate('xpack.apm.transactionActionMenu.status.title', {

View file

@ -125,11 +125,7 @@ function ActionMenuSections({
transaction?: Transaction;
profilingLocators?: ProfilingLocators;
}) {
const {
core,
uiActions,
infra: { locators },
} = useApmPluginContext();
const { core, uiActions, infra } = useApmPluginContext();
const location = useLocation();
const apmRouter = useApmRouter();
@ -151,7 +147,7 @@ function ActionMenuSections({
basePath: core.http.basePath,
location,
apmRouter,
infraLocators: locators,
infraLocators: infra?.locators,
infraLinksAvailable,
profilingLocators,
rangeFrom,

View file

@ -128,7 +128,7 @@ export interface ApmPluginStartDeps {
fieldFormats?: FieldFormatsStart;
security?: SecurityPluginStart;
spaces?: SpacesPluginStart;
infra: InfraClientStartExports;
infra?: InfraClientStartExports;
dataViews: DataViewsPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
storage: IStorageWrapper;

View file

@ -15,6 +15,9 @@ export async function getInfraMetricIndices({
infraPlugin: Required<APMRouteHandlerResources['plugins']['infra']>;
savedObjectsClient: SavedObjectsClientContract;
}): Promise<string> {
if (!infraPlugin) {
throw new Error('Infra Plugin needs to be setup');
}
const infra = await infraPlugin.start();
const infraMetricIndices = await infra.getMetricIndices(savedObjectsClient);

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import * as t from 'io-ts';
import Boom from '@hapi/boom';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import { getApmEventClient } from '../../lib/helpers/get_apm_event_client';
import { environmentRt, kueryRt, rangeRt } from '../default_api_types';
@ -29,9 +30,12 @@ const infrastructureRoute = createApmServerRoute({
hostNames: string[];
podNames: string[];
}> => {
if (!resources.plugins.infra) {
throw Boom.notFound();
}
const apmEventClient = await getApmEventClient(resources);
const infraMetricsClient = createInfraMetricsClient(resources);
const { params } = resources;
const {

View file

@ -239,7 +239,6 @@ const serviceMetadataDetailsRoute = createApmServerRoute({
options: { tags: ['access:apm'] },
handler: async (resources): Promise<ServiceMetadataDetails> => {
const apmEventClient = await getApmEventClient(resources);
const infraMetricsClient = createInfraMetricsClient(resources);
const { params } = resources;
const { serviceName } = params.path;
const { start, end } = params.query;
@ -251,7 +250,8 @@ const serviceMetadataDetailsRoute = createApmServerRoute({
end,
});
if (serviceMetadataDetails?.container?.ids) {
if (serviceMetadataDetails?.container?.ids && resources.plugins.infra) {
const infraMetricsClient = createInfraMetricsClient(resources);
const containerMetadata = await getServiceOverviewContainerMetadata({
infraMetricsClient,
containerIds: serviceMetadataDetails.container.ids,
@ -748,7 +748,6 @@ export const serviceInstancesMetadataDetails = createApmServerRoute({
(ServiceInstanceContainerMetadataDetails | {})
> => {
const apmEventClient = await getApmEventClient(resources);
const infraMetricsClient = createInfraMetricsClient(resources);
const { params } = resources;
const { serviceName, serviceNodeName } = params.path;
const { start, end } = params.query;
@ -762,7 +761,11 @@ export const serviceInstancesMetadataDetails = createApmServerRoute({
end,
});
if (serviceInstanceMetadataDetails?.container?.id) {
if (
serviceInstanceMetadataDetails?.container?.id &&
resources.plugins.infra
) {
const infraMetricsClient = createInfraMetricsClient(resources);
const containerMetadata = await getServiceInstanceContainerMetadata({
infraMetricsClient,
containerId: serviceInstanceMetadataDetails.container.id,

View file

@ -75,7 +75,7 @@ export interface APMPluginSetupDependencies {
licensing: LicensingPluginSetup;
observability: ObservabilityPluginSetup;
ruleRegistry: RuleRegistryPluginSetupContract;
infra: InfraPluginSetup;
infra?: InfraPluginSetup;
dataViews: {};
share: SharePluginSetup;

View file

@ -17,7 +17,6 @@
"observabilityShared",
"observabilityAIAssistant",
"embeddable",
"infra",
"inspector",
"apm"
],