mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] Fix spaces issue for static index patterns (#95799)
This commit is contained in:
parent
0cdf445718
commit
e0a1fe18be
6 changed files with 35 additions and 11 deletions
|
@ -12,6 +12,7 @@
|
|||
"infra"
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"spaces",
|
||||
"cloud",
|
||||
"usageCollection",
|
||||
"taskManager",
|
||||
|
|
|
@ -36,7 +36,12 @@ describe('createStaticIndexPattern', () => {
|
|||
'xpack.apm.autocreateApmIndexPattern': false,
|
||||
});
|
||||
const savedObjectsClient = getMockSavedObjectsClient();
|
||||
await createStaticIndexPattern(setup, context, savedObjectsClient);
|
||||
await createStaticIndexPattern(
|
||||
setup,
|
||||
context,
|
||||
savedObjectsClient,
|
||||
'default'
|
||||
);
|
||||
expect(savedObjectsClient.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -53,7 +58,12 @@ describe('createStaticIndexPattern', () => {
|
|||
|
||||
const savedObjectsClient = getMockSavedObjectsClient();
|
||||
|
||||
await createStaticIndexPattern(setup, context, savedObjectsClient);
|
||||
await createStaticIndexPattern(
|
||||
setup,
|
||||
context,
|
||||
savedObjectsClient,
|
||||
'default'
|
||||
);
|
||||
expect(savedObjectsClient.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -70,7 +80,12 @@ describe('createStaticIndexPattern', () => {
|
|||
|
||||
const savedObjectsClient = getMockSavedObjectsClient();
|
||||
|
||||
await createStaticIndexPattern(setup, context, savedObjectsClient);
|
||||
await createStaticIndexPattern(
|
||||
setup,
|
||||
context,
|
||||
savedObjectsClient,
|
||||
'default'
|
||||
);
|
||||
|
||||
expect(savedObjectsClient.create).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,8 @@ import { getApmIndexPatternTitle } from './get_apm_index_pattern_title';
|
|||
export async function createStaticIndexPattern(
|
||||
setup: Setup,
|
||||
context: APMRequestHandlerContext,
|
||||
savedObjectsClient: InternalSavedObjectsClient
|
||||
savedObjectsClient: InternalSavedObjectsClient,
|
||||
spaceId: string | undefined
|
||||
): Promise<boolean> {
|
||||
return withApmSpan('create_static_index_pattern', async () => {
|
||||
const { config } = context;
|
||||
|
@ -46,7 +47,11 @@ export async function createStaticIndexPattern(
|
|||
...apmIndexPattern.attributes,
|
||||
title: apmIndexPatternTitle,
|
||||
},
|
||||
{ id: APM_STATIC_INDEX_PATTERN_ID, overwrite: false }
|
||||
{
|
||||
id: APM_STATIC_INDEX_PATTERN_ID,
|
||||
overwrite: false,
|
||||
namespace: spaceId,
|
||||
}
|
||||
)
|
||||
);
|
||||
return true;
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
Plugin,
|
||||
PluginInitializerContext,
|
||||
} from 'src/core/server';
|
||||
import { SpacesPluginSetup } from '../../spaces/server';
|
||||
import { APMConfig, APMXPackConfig } from '.';
|
||||
import { mergeConfigs } from './index';
|
||||
import { APMOSSPluginSetup } from '../../../../src/plugins/apm_oss/server';
|
||||
|
@ -65,6 +66,7 @@ export class APMPlugin implements Plugin<APMPluginSetup> {
|
|||
public setup(
|
||||
core: CoreSetup,
|
||||
plugins: {
|
||||
spaces?: SpacesPluginSetup;
|
||||
apmOss: APMOSSPluginSetup;
|
||||
home: HomeServerPluginSetup;
|
||||
licensing: LicensingPluginSetup;
|
||||
|
@ -148,11 +150,7 @@ export class APMPlugin implements Plugin<APMPluginSetup> {
|
|||
createApmApi().init(core, {
|
||||
config$: mergedConfig$,
|
||||
logger: this.logger!,
|
||||
plugins: {
|
||||
observability: plugins.observability,
|
||||
security: plugins.security,
|
||||
ml: plugins.ml,
|
||||
},
|
||||
plugins,
|
||||
});
|
||||
|
||||
const boundGetApmIndices = async () =>
|
||||
|
|
|
@ -21,10 +21,13 @@ export const staticIndexPatternRoute = createRoute((core) => ({
|
|||
getInternalSavedObjectsClient(core),
|
||||
]);
|
||||
|
||||
const spaceId = context.plugins.spaces?.spacesService.getSpaceId(request);
|
||||
|
||||
const didCreateIndexPattern = await createStaticIndexPattern(
|
||||
setup,
|
||||
context,
|
||||
savedObjectsClient
|
||||
savedObjectsClient,
|
||||
spaceId
|
||||
);
|
||||
|
||||
return { created: didCreateIndexPattern };
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
} from 'src/core/server';
|
||||
import { Observable } from 'rxjs';
|
||||
import { RequiredKeys, DeepPartial } from 'utility-types';
|
||||
import { SpacesPluginStart } from '../../../spaces/server';
|
||||
import { ObservabilityPluginSetup } from '../../../observability/server';
|
||||
import { LicensingApiRequestHandlerContext } from '../../../licensing/server';
|
||||
import { SecurityPluginSetup } from '../../../security/server';
|
||||
|
@ -93,6 +94,7 @@ export type APMRequestHandlerContext<
|
|||
config: APMConfig;
|
||||
logger: Logger;
|
||||
plugins: {
|
||||
spaces?: SpacesPluginStart;
|
||||
observability?: ObservabilityPluginSetup;
|
||||
security?: SecurityPluginSetup;
|
||||
ml?: MlPluginSetup;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue