Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion x-pack/plugins/observability/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"alerting",
"ruleRegistry",
"triggersActionsUi",
"cases"
"cases",
"features"
],
"ui": true,
"server": true,
Expand Down
86 changes: 79 additions & 7 deletions x-pack/plugins/observability/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
* 2.0.
*/

import { PluginInitializerContext, Plugin, CoreSetup } from 'src/core/server';
import { i18n } from '@kbn/i18n';
import {
PluginInitializerContext,
Plugin,
CoreSetup,
DEFAULT_APP_CATEGORIES,
} from '../../../../src/core/server';
import { RuleDataClient } from '../../rule_registry/server';
import { ObservabilityConfig } from '.';
import {
Expand All @@ -14,23 +20,89 @@ import {
AnnotationsAPI,
} from './lib/annotations/bootstrap_annotations';
import type { RuleRegistryPluginSetupContract } from '../../rule_registry/server';
import { PluginSetupContract as FeaturesSetup } from '../../features/server';
import { uiSettings } from './ui_settings';
import { registerRoutes } from './routes/register_routes';
import { getGlobalObservabilityServerRouteRepository } from './routes/get_global_observability_server_route_repository';
import {
CASE_COMMENT_SAVED_OBJECT,
CASE_CONFIGURE_SAVED_OBJECT,
CASE_SAVED_OBJECT,
CASE_USER_ACTION_SAVED_OBJECT,
} from '../../cases/common';

export type ObservabilityPluginSetup = ReturnType<ObservabilityPlugin['setup']>;

interface PluginSetup {
features: FeaturesSetup;
ruleRegistry: RuleRegistryPluginSetupContract;
}

const caseSavedObjects = [
CASE_SAVED_OBJECT,
CASE_USER_ACTION_SAVED_OBJECT,
CASE_COMMENT_SAVED_OBJECT,
CASE_CONFIGURE_SAVED_OBJECT,
];

const OBS_CASES_ID = 'observabilityCases';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Chose camel case here because that seems to be what is used in the tests I had to update 🤷‍♂️

const OBSERVABILITY = 'observability';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can probably move this to your constants file or just replace it with CASES_OWNER.


export class ObservabilityPlugin implements Plugin<ObservabilityPluginSetup> {
constructor(private readonly initContext: PluginInitializerContext) {
this.initContext = initContext;
}

public setup(
core: CoreSetup,
plugins: {
ruleRegistry: RuleRegistryPluginSetupContract;
}
) {
public setup(core: CoreSetup, plugins: PluginSetup) {
plugins.features.registerKibanaFeature({
id: OBS_CASES_ID,
name: i18n.translate('xpack.observability.featureRegistry.linkSecuritySolutionTitle', {
defaultMessage: 'Cases',
}),
order: 1100,
category: DEFAULT_APP_CATEGORIES.observability,
app: [OBS_CASES_ID, 'kibana'],
catalogue: [OBSERVABILITY],
cases: [OBSERVABILITY],
management: {
insightsAndAlerting: ['triggersActions'],
},
privileges: {
all: {
app: [OBS_CASES_ID, 'kibana'],
catalogue: [OBSERVABILITY],
cases: {
all: [OBSERVABILITY],
},
api: [],
savedObject: {
all: [...caseSavedObjects],
read: ['config'],
},
management: {
insightsAndAlerting: ['triggersActions'],
},
ui: ['crud_cases', 'read_cases'], // uiCapabilities.observabilityCases.crud_cases or read_cases
},
read: {
app: [OBS_CASES_ID, 'kibana'],
catalogue: [OBSERVABILITY],
cases: {
read: [OBSERVABILITY],
},
api: [],
savedObject: {
all: [],
read: ['config', ...caseSavedObjects],
},
management: {
insightsAndAlerting: ['triggersActions'],
},
ui: ['read_cases'], // uiCapabilities.observabilityCases.read_cases
},
},
});

const config = this.initContext.config.get<ObservabilityConfig>();

let annotationsApiPromise: Promise<AnnotationsAPI> | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default function ({ getService }: FtrProviderContext) {
'infrastructure',
'logs',
'maps',
'observabilityCases',
'uptime',
'siem',
'fleet',
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/api_integration/apis/security/privileges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function ({ getService }: FtrProviderContext) {
canvas: ['all', 'read', 'minimal_all', 'minimal_read', 'generate_report'],
infrastructure: ['all', 'read'],
logs: ['all', 'read'],
observabilityCases: ['all', 'read'],
uptime: ['all', 'read'],
apm: ['all', 'read'],
ml: ['all', 'read'],
Expand Down