Skip to content

Commit

Permalink
Makes spaces optional in observability plugin (#151147)
Browse files Browse the repository at this point in the history
## Summary

This PR makes spaces optional in the "observability" plugin as requested
in #149687

To test this, use the following setting in your kibana.yml config file:

```yaml
xpack.spaces.enabled: false
```

When you log in, there will be no spaces choice. 

<img width="2543" alt="Screenshot 2023-02-21 at 11 53 18 AM"
src="https://user-images.githubusercontent.com/159370/220409537-43a216d5-81c9-4b29-97d8-47705bdacd06.png">
  • Loading branch information
jasonrhodes authored Mar 1, 2023
1 parent d051183 commit 5e397c4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
3 changes: 1 addition & 2 deletions x-pack/plugins/observability/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"unifiedSearch",
"security",
"guidedOnboarding",
"share",
"spaces"
"share"
],
"optionalPlugins": [
"discover",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useKibanaSpace = () => {
data: space,
loading,
error,
} = useFetcher<Promise<Space>>(() => {
} = useFetcher<Promise<Space> | undefined>(() => {
return services.spaces?.getActiveSpace();
}, [services.spaces]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@ export const useOverviewMetrics = ({ hasAnyData }: { hasAnyData: boolean | undef
}

CAPABILITIES_KEYS.forEach((feature) => {
if (capabilities[feature].show === false) {
const name = feature === 'infrastructure' ? 'metrics' : feature;

// Track metric if the feature has been disabled, either because it
// is missing or has show === false (manual disabling may not be
// possible in all versions of Kibana)
if (!capabilities[feature] || capabilities[feature]?.show === false) {
trackMetric({
metric: `oblt_disabled_feature_${name}`,
});
}

// Track a separate metric if the feature is missing from the capabilities
// (This usually means the plugin was auto-disabled by Kibana)
if (!capabilities[feature]) {
trackMetric({
metric: `oblt_disabled_feature_${feature === 'infrastructure' ? 'metrics' : feature}`,
metric: `oblt_missing_feature_${name}`,
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export interface ObservabilityPublicPluginsStart {
ruleTypeRegistry: RuleTypeRegistryContract;
security: SecurityPluginStart;
share: SharePluginStart;
spaces: SpacesPluginStart;
spaces?: SpacesPluginStart;
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
usageCollection: UsageCollectionSetup;
unifiedSearch: UnifiedSearchPublicPluginStart;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/observability/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { PluginSetupContract } from '@kbn/alerting-plugin/server';
import { Dataset, RuleRegistryPluginSetupContract } from '@kbn/rule-registry-plugin/server';
import { PluginSetupContract as FeaturesSetup } from '@kbn/features-plugin/server';
import { createUICapabilities } from '@kbn/cases-plugin/common';
import { SpacesPluginSetup } from '@kbn/spaces-plugin/server';
import { experimentalRuleFieldMap } from '@kbn/rule-registry-plugin/common/assets/field_maps/experimental_rule_field_map';
import { ECS_COMPONENT_TEMPLATE_NAME } from '@kbn/alerting-plugin/server';
import type { GuidedOnboardingPluginSetup } from '@kbn/guided-onboarding-plugin/server';
Expand Down Expand Up @@ -50,6 +51,7 @@ interface PluginSetup {
features: FeaturesSetup;
guidedOnboarding: GuidedOnboardingPluginSetup;
ruleRegistry: RuleRegistryPluginSetupContract;
spaces?: SpacesPluginSetup;
usageCollection?: UsageCollectionSetup;
}

Expand Down

0 comments on commit 5e397c4

Please sign in to comment.