2020-04-30 22:08:50 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { i18n } from '@kbn/i18n';
|
2020-09-18 10:14:13 +02:00
|
|
|
import { LicenseType } from '../../licensing/common/types';
|
2020-07-22 15:45:57 +02:00
|
|
|
import { AlertType } from '../common/alert_types';
|
2020-09-18 18:30:59 +02:00
|
|
|
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';
|
2020-09-18 10:14:13 +02:00
|
|
|
import {
|
|
|
|
LicensingPluginSetup,
|
|
|
|
LicensingRequestHandlerContext,
|
|
|
|
} from '../../licensing/server';
|
2020-04-30 22:08:50 +02:00
|
|
|
|
|
|
|
export const APM_FEATURE = {
|
|
|
|
id: 'apm',
|
|
|
|
name: i18n.translate('xpack.apm.featureRegistry.apmFeatureName', {
|
2020-09-24 13:26:00 +02:00
|
|
|
defaultMessage: 'APM and User Experience',
|
2020-04-30 22:08:50 +02:00
|
|
|
}),
|
|
|
|
order: 900,
|
2020-09-18 18:30:59 +02:00
|
|
|
category: DEFAULT_APP_CATEGORIES.observability,
|
2020-04-30 22:08:50 +02:00
|
|
|
icon: 'apmApp',
|
|
|
|
navLinkId: 'apm',
|
2020-09-24 13:26:00 +02:00
|
|
|
app: ['apm', 'ux', 'kibana'],
|
2020-04-30 22:08:50 +02:00
|
|
|
catalogue: ['apm'],
|
2020-07-28 16:20:24 +02:00
|
|
|
management: {
|
|
|
|
insightsAndAlerting: ['triggersActions'],
|
|
|
|
},
|
2020-07-22 15:45:57 +02:00
|
|
|
alerting: Object.values(AlertType),
|
2020-04-30 22:08:50 +02:00
|
|
|
// see x-pack/plugins/features/common/feature_kibana_privileges.ts
|
|
|
|
privileges: {
|
|
|
|
all: {
|
2020-09-24 13:26:00 +02:00
|
|
|
app: ['apm', 'ux', 'kibana'],
|
2020-07-22 15:45:57 +02:00
|
|
|
api: ['apm', 'apm_write'],
|
2020-04-30 22:08:50 +02:00
|
|
|
catalogue: ['apm'],
|
|
|
|
savedObject: {
|
2020-07-22 15:45:57 +02:00
|
|
|
all: [],
|
2020-05-22 09:08:58 +02:00
|
|
|
read: [],
|
2020-04-30 22:08:50 +02:00
|
|
|
},
|
2020-07-22 15:45:57 +02:00
|
|
|
alerting: {
|
|
|
|
all: Object.values(AlertType),
|
|
|
|
},
|
2020-07-28 16:20:24 +02:00
|
|
|
management: {
|
|
|
|
insightsAndAlerting: ['triggersActions'],
|
|
|
|
},
|
2020-07-22 15:45:57 +02:00
|
|
|
ui: ['show', 'save', 'alerting:show', 'alerting:save'],
|
2020-04-30 22:08:50 +02:00
|
|
|
},
|
|
|
|
read: {
|
2020-09-24 13:26:00 +02:00
|
|
|
app: ['apm', 'ux', 'kibana'],
|
2020-07-22 15:45:57 +02:00
|
|
|
api: ['apm'],
|
2020-04-30 22:08:50 +02:00
|
|
|
catalogue: ['apm'],
|
|
|
|
savedObject: {
|
2020-07-22 15:45:57 +02:00
|
|
|
all: [],
|
2020-05-22 09:08:58 +02:00
|
|
|
read: [],
|
2020-04-30 22:08:50 +02:00
|
|
|
},
|
2020-07-22 15:45:57 +02:00
|
|
|
alerting: {
|
|
|
|
all: Object.values(AlertType),
|
|
|
|
},
|
2020-07-28 16:20:24 +02:00
|
|
|
management: {
|
|
|
|
insightsAndAlerting: ['triggersActions'],
|
|
|
|
},
|
2020-07-22 15:45:57 +02:00
|
|
|
ui: ['show', 'alerting:show', 'alerting:save'],
|
2020-05-22 09:08:58 +02:00
|
|
|
},
|
|
|
|
},
|
2020-04-30 22:08:50 +02:00
|
|
|
};
|
2020-06-18 02:18:15 +02:00
|
|
|
|
2020-09-18 10:14:13 +02:00
|
|
|
interface Feature {
|
|
|
|
name: string;
|
|
|
|
license: LicenseType;
|
|
|
|
}
|
|
|
|
type FeatureName = 'serviceMaps' | 'ml' | 'customLinks';
|
|
|
|
export const features: Record<FeatureName, Feature> = {
|
|
|
|
serviceMaps: {
|
|
|
|
name: 'APM service maps',
|
|
|
|
license: 'platinum',
|
|
|
|
},
|
|
|
|
ml: {
|
|
|
|
name: 'APM machine learning',
|
|
|
|
license: 'platinum',
|
|
|
|
},
|
|
|
|
customLinks: {
|
|
|
|
name: 'APM custom links',
|
|
|
|
license: 'gold',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export function registerFeaturesUsage({
|
|
|
|
licensingPlugin,
|
|
|
|
}: {
|
|
|
|
licensingPlugin: LicensingPluginSetup;
|
|
|
|
}) {
|
|
|
|
Object.values(features).forEach(({ name, license }) => {
|
|
|
|
licensingPlugin.featureUsage.register(name, license);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function notifyFeatureUsage({
|
|
|
|
licensingPlugin,
|
|
|
|
featureName,
|
|
|
|
}: {
|
|
|
|
licensingPlugin: LicensingRequestHandlerContext;
|
|
|
|
featureName: FeatureName;
|
|
|
|
}) {
|
|
|
|
const feature = features[featureName];
|
|
|
|
licensingPlugin.featureUsage.notifyUsage(feature.name);
|
|
|
|
}
|