mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
## Summary See the included help file for more details: [`x-pack/examples/alerting_example/server/alert_types/pattern.md`](https://github.com/pmuellr/kibana/blob/main/x-pack/examples/alerting_example/server/alert_types/pattern.md). --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
88 lines
3 KiB
TypeScript
88 lines
3 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import { Plugin, CoreSetup } from '@kbn/core/server';
|
|
import { i18n } from '@kbn/i18n';
|
|
// import directly to support examples functional tests (@kbn-test/src/functional_tests/lib/babel_register_for_test_plugins.js)
|
|
import { DEFAULT_APP_CATEGORIES } from '@kbn/core-application-common';
|
|
import { PluginSetupContract as AlertingSetup } from '@kbn/alerting-plugin/server';
|
|
import { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server';
|
|
|
|
import { alertType as alwaysFiringAlert } from './alert_types/always_firing';
|
|
import { alertType as peopleInSpaceAlert } from './alert_types/astros';
|
|
import { alertType as patternAlert } from './alert_types/pattern';
|
|
// can't import static code from another plugin to support examples functional test
|
|
const INDEX_THRESHOLD_ID = '.index-threshold';
|
|
import { ALERTING_EXAMPLE_APP_ID } from '../common/constants';
|
|
|
|
// this plugin's dependencies
|
|
export interface AlertingExampleDeps {
|
|
alerting: AlertingSetup;
|
|
features: FeaturesPluginSetup;
|
|
}
|
|
|
|
export class AlertingExamplePlugin implements Plugin<void, void, AlertingExampleDeps> {
|
|
public setup(core: CoreSetup, { alerting, features }: AlertingExampleDeps) {
|
|
alerting.registerType(alwaysFiringAlert);
|
|
alerting.registerType(peopleInSpaceAlert);
|
|
alerting.registerType(patternAlert);
|
|
|
|
features.registerKibanaFeature({
|
|
id: ALERTING_EXAMPLE_APP_ID,
|
|
name: i18n.translate('alertsExample.featureRegistry.alertsExampleFeatureName', {
|
|
defaultMessage: 'Alerting Examples',
|
|
}),
|
|
app: [],
|
|
management: {
|
|
insightsAndAlerting: ['triggersActions'],
|
|
},
|
|
category: DEFAULT_APP_CATEGORIES.management,
|
|
alerting: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
|
|
privileges: {
|
|
all: {
|
|
alerting: {
|
|
rule: {
|
|
all: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
|
|
},
|
|
alert: {
|
|
all: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
|
|
},
|
|
},
|
|
savedObject: {
|
|
all: [],
|
|
read: [],
|
|
},
|
|
management: {
|
|
insightsAndAlerting: ['triggersActions'],
|
|
},
|
|
ui: [],
|
|
},
|
|
read: {
|
|
alerting: {
|
|
rule: {
|
|
read: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
|
|
},
|
|
alert: {
|
|
read: [alwaysFiringAlert.id, peopleInSpaceAlert.id, INDEX_THRESHOLD_ID],
|
|
},
|
|
},
|
|
savedObject: {
|
|
all: [],
|
|
read: [],
|
|
},
|
|
management: {
|
|
insightsAndAlerting: ['triggersActions'],
|
|
},
|
|
ui: [],
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
public start() {}
|
|
public stop() {}
|
|
}
|