Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
parent
16d5bbb1b3
commit
f9abd1789b
29 changed files with 166 additions and 381 deletions
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export const ALERTING_EXAMPLE_APP_ID = 'AlertingExample';
|
||||
|
||||
// always firing
|
||||
export const DEFAULT_INSTANCES_TO_GENERATE = 5;
|
||||
|
||||
// Astros
|
||||
export enum Craft {
|
||||
OuterSpace = 'Outer Space',
|
||||
ISS = 'ISS',
|
||||
}
|
||||
export enum Operator {
|
||||
AreAbove = 'Are above',
|
||||
AreBelow = 'Are below',
|
||||
AreExactly = 'Are exactly',
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { registerNavigation as registerPeopleInSpaceNavigation } from './astros';
|
||||
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
import { SanitizedAlert } from '../../../../x-pack/plugins/alerts/common';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerts/public';
|
||||
|
||||
export function registerNavigation(alerts: AlertingSetup) {
|
||||
// register default navigation
|
||||
alerts.registerDefaultNavigation(
|
||||
ALERTING_EXAMPLE_APP_ID,
|
||||
(alert: SanitizedAlert) => `/alert/${alert.id}`
|
||||
);
|
||||
|
||||
registerPeopleInSpaceNavigation(alerts);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { AlertingExamplePlugin } from './plugin';
|
||||
|
||||
export const plugin = () => new AlertingExamplePlugin();
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import uuid from 'uuid';
|
||||
import { range } from 'lodash';
|
||||
import { AlertType } from '../../../../x-pack/plugins/alerts/server';
|
||||
import { DEFAULT_INSTANCES_TO_GENERATE, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
|
||||
export const alertType: AlertType = {
|
||||
id: 'example.always-firing',
|
||||
name: 'Always firing',
|
||||
actionGroups: [{ id: 'default', name: 'default' }],
|
||||
defaultActionGroupId: 'default',
|
||||
async executor({ services, params: { instances = DEFAULT_INSTANCES_TO_GENERATE }, state }) {
|
||||
const count = (state.count ?? 0) + 1;
|
||||
|
||||
range(instances)
|
||||
.map(() => ({ id: uuid.v4() }))
|
||||
.forEach((instance: { id: string }) => {
|
||||
services
|
||||
.alertInstanceFactory(instance.id)
|
||||
.replaceState({ triggerdOnCycle: count })
|
||||
.scheduleActions('default');
|
||||
});
|
||||
|
||||
return {
|
||||
count,
|
||||
};
|
||||
},
|
||||
producer: ALERTING_EXAMPLE_APP_ID,
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializer } from 'kibana/server';
|
||||
import { AlertingExamplePlugin } from './plugin';
|
||||
|
||||
export const plugin: PluginInitializer<void, void> = () => new AlertingExamplePlugin();
|
|
@ -161,7 +161,8 @@ export class OptimizerConfig {
|
|||
Path.resolve(repoRoot, 'src/plugins'),
|
||||
...(oss ? [] : [Path.resolve(repoRoot, 'x-pack/plugins')]),
|
||||
Path.resolve(repoRoot, 'plugins'),
|
||||
...(examples ? [Path.resolve('examples'), Path.resolve('x-pack/examples')] : []),
|
||||
...(examples ? [Path.resolve('examples')] : []),
|
||||
...(examples && !oss ? [Path.resolve('x-pack/examples')] : []),
|
||||
Path.resolve(repoRoot, '../kibana-extra'),
|
||||
];
|
||||
if (!pluginScanDirs.every((p) => Path.isAbsolute(p))) {
|
||||
|
|
|
@ -5,7 +5,6 @@ source src/dev/ci_setup/setup_env.sh
|
|||
echo " -> building kibana platform plugins"
|
||||
node scripts/build_kibana_platform_plugins \
|
||||
--oss \
|
||||
--filter '!alertingExample' \
|
||||
--scan-dir "$KIBANA_DIR/test/plugin_functional/plugins" \
|
||||
--scan-dir "$KIBANA_DIR/test/interpreter_functional/plugins" \
|
||||
--workers 6 \
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
"prefix": "xpack",
|
||||
"paths": {
|
||||
"xpack.actions": "plugins/actions",
|
||||
"xpack.uiActionsEnhanced": [
|
||||
"plugins/ui_actions_enhanced",
|
||||
"examples/ui_actions_enhanced_examples"
|
||||
],
|
||||
"xpack.uiActionsEnhanced": "plugins/ui_actions_enhanced",
|
||||
"xpack.alerts": "plugins/alerts",
|
||||
"xpack.eventLog": "plugins/event_log",
|
||||
"xpack.alertingBuiltins": "plugins/alerting_builtins",
|
||||
|
@ -59,6 +56,9 @@
|
|||
"xpack.watcher": "plugins/watcher",
|
||||
"xpack.observability": "plugins/observability"
|
||||
},
|
||||
"exclude": [
|
||||
"examples"
|
||||
],
|
||||
"translations": [
|
||||
"plugins/translations/translations/zh-CN.json",
|
||||
"plugins/translations/translations/ja-JP.json"
|
||||
|
|
21
x-pack/examples/alerting_example/common/constants.ts
Normal file
21
x-pack/examples/alerting_example/common/constants.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const ALERTING_EXAMPLE_APP_ID = 'AlertingExample';
|
||||
|
||||
// always firing
|
||||
export const DEFAULT_INSTANCES_TO_GENERATE = 5;
|
||||
|
||||
// Astros
|
||||
export enum Craft {
|
||||
OuterSpace = 'Outer Space',
|
||||
ISS = 'ISS',
|
||||
}
|
||||
export enum Operator {
|
||||
AreAbove = 'Are above',
|
||||
AreBelow = 'Are below',
|
||||
AreExactly = 'Are exactly',
|
||||
}
|
|
@ -1,26 +1,13 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React, { Fragment } from 'react';
|
||||
import { EuiFlexGroup, EuiFlexItem, EuiFieldNumber, EuiFormRow } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { AlertTypeModel } from '../../../../x-pack/plugins/triggers_actions_ui/public';
|
||||
import { AlertTypeModel } from '../../../../plugins/triggers_actions_ui/public';
|
||||
import { DEFAULT_INSTANCES_TO_GENERATE } from '../../common/constants';
|
||||
|
||||
interface AlwaysFiringParamsProps {
|
|
@ -1,20 +1,7 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React, { useState, useEffect, Fragment } from 'react';
|
||||
|
@ -32,9 +19,9 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { flatten } from 'lodash';
|
||||
import { ALERTING_EXAMPLE_APP_ID, Craft, Operator } from '../../common/constants';
|
||||
import { SanitizedAlert } from '../../../../x-pack/plugins/alerts/common';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerts/public';
|
||||
import { AlertTypeModel } from '../../../../x-pack/plugins/triggers_actions_ui/public';
|
||||
import { SanitizedAlert } from '../../../../plugins/alerts/common';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../../plugins/alerts/public';
|
||||
import { AlertTypeModel } from '../../../../plugins/triggers_actions_ui/public';
|
||||
|
||||
export function registerNavigation(alerts: AlertingSetup) {
|
||||
alerts.registerNavigation(
|
20
x-pack/examples/alerting_example/public/alert_types/index.ts
Normal file
20
x-pack/examples/alerting_example/public/alert_types/index.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* 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 { registerNavigation as registerPeopleInSpaceNavigation } from './astros';
|
||||
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
import { SanitizedAlert } from '../../../../plugins/alerts/common';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../../plugins/alerts/public';
|
||||
|
||||
export function registerNavigation(alerts: AlertingSetup) {
|
||||
// register default navigation
|
||||
alerts.registerDefaultNavigation(
|
||||
ALERTING_EXAMPLE_APP_ID,
|
||||
(alert: SanitizedAlert) => `/alert/${alert.id}`
|
||||
);
|
||||
|
||||
registerPeopleInSpaceNavigation(alerts);
|
||||
}
|
|
@ -1,20 +1,7 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React from 'react';
|
||||
|
@ -28,14 +15,14 @@ import {
|
|||
DocLinksStart,
|
||||
ToastsSetup,
|
||||
ApplicationStart,
|
||||
} from '../../../src/core/public';
|
||||
import { DataPublicPluginStart } from '../../../src/plugins/data/public';
|
||||
import { ChartsPluginStart } from '../../../src/plugins/charts/public';
|
||||
} from '../../../../src/core/public';
|
||||
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
|
||||
import { ChartsPluginStart } from '../../../../src/plugins/charts/public';
|
||||
|
||||
import { Page } from './components/page';
|
||||
import { DocumentationPage } from './components/documentation';
|
||||
import { ViewAlertPage } from './components/view_alert';
|
||||
import { TriggersAndActionsUIPublicPluginStart } from '../../../x-pack/plugins/triggers_actions_ui/public';
|
||||
import { TriggersAndActionsUIPublicPluginStart } from '../../../plugins/triggers_actions_ui/public';
|
||||
import { AlertingExamplePublicStartDeps } from './plugin';
|
||||
import { ViewPeopleInSpaceAlertPage } from './components/view_astros_alert';
|
||||
|
|
@ -1,30 +1,14 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React, { useState } from 'react';
|
||||
|
||||
import { EuiIcon, EuiFlexItem, EuiCard, EuiFlexGroup } from '@elastic/eui';
|
||||
|
||||
import {
|
||||
AlertsContextProvider,
|
||||
AlertAdd,
|
||||
} from '../../../../x-pack/plugins/triggers_actions_ui/public';
|
||||
import { AlertsContextProvider, AlertAdd } from '../../../../plugins/triggers_actions_ui/public';
|
||||
import { AlertingExampleComponentParams } from '../application';
|
||||
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
|
|
@ -1,21 +1,9 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React from 'react';
|
||||
|
||||
import {
|
|
@ -1,20 +1,7 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React from 'react';
|
|
@ -1,21 +1,9 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React, { useState, useEffect, Fragment } from 'react';
|
||||
|
||||
import {
|
||||
|
@ -32,11 +20,7 @@ import {
|
|||
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
||||
import { CoreStart } from 'kibana/public';
|
||||
import { isEmpty } from 'lodash';
|
||||
import {
|
||||
Alert,
|
||||
AlertTaskState,
|
||||
BASE_ALERT_API_PATH,
|
||||
} from '../../../../x-pack/plugins/alerts/common';
|
||||
import { Alert, AlertTaskState, BASE_ALERT_API_PATH } from '../../../../plugins/alerts/common';
|
||||
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
|
||||
type Props = RouteComponentProps & {
|
|
@ -1,21 +1,9 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 React, { useState, useEffect, Fragment } from 'react';
|
||||
|
||||
import {
|
||||
|
@ -34,11 +22,7 @@ import {
|
|||
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
||||
import { CoreStart } from 'kibana/public';
|
||||
import { isEmpty } from 'lodash';
|
||||
import {
|
||||
Alert,
|
||||
AlertTaskState,
|
||||
BASE_ALERT_API_PATH,
|
||||
} from '../../../../x-pack/plugins/alerts/common';
|
||||
import { Alert, AlertTaskState, BASE_ALERT_API_PATH } from '../../../../plugins/alerts/common';
|
||||
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
|
||||
type Props = RouteComponentProps & {
|
9
x-pack/examples/alerting_example/public/index.ts
Normal file
9
x-pack/examples/alerting_example/public/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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 { AlertingExamplePlugin } from './plugin';
|
||||
|
||||
export const plugin = () => new AlertingExamplePlugin();
|
|
@ -1,31 +1,23 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 { Plugin, CoreSetup, AppMountParameters, AppNavLinkStatus } from '../../../src/core/public';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/public';
|
||||
import { ChartsPluginStart } from '../../../src/plugins/charts/public';
|
||||
import { TriggersAndActionsUIPublicPluginSetup } from '../../../x-pack/plugins/triggers_actions_ui/public';
|
||||
import { DataPublicPluginStart } from '../../../src/plugins/data/public';
|
||||
import {
|
||||
Plugin,
|
||||
CoreSetup,
|
||||
AppMountParameters,
|
||||
AppNavLinkStatus,
|
||||
} from '../../../../src/core/public';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../plugins/alerts/public';
|
||||
import { ChartsPluginStart } from '../../../../src/plugins/charts/public';
|
||||
import { TriggersAndActionsUIPublicPluginSetup } from '../../../plugins/triggers_actions_ui/public';
|
||||
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
|
||||
import { getAlertType as getAlwaysFiringAlertType } from './alert_types/always_firing';
|
||||
import { getAlertType as getPeopleInSpaceAlertType } from './alert_types/astros';
|
||||
import { registerNavigation } from './alert_types';
|
||||
import { DeveloperExamplesSetup } from '../../developer_examples/public';
|
||||
import { DeveloperExamplesSetup } from '../../../../examples/developer_examples/public';
|
||||
|
||||
export type Setup = void;
|
||||
export type Start = void;
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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 uuid from 'uuid';
|
||||
import { range } from 'lodash';
|
||||
import { AlertType } from '../../../../plugins/alerts/server';
|
||||
import { DEFAULT_INSTANCES_TO_GENERATE, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
|
||||
export const alertType: AlertType = {
|
||||
id: 'example.always-firing',
|
||||
name: 'Always firing',
|
||||
actionGroups: [{ id: 'default', name: 'default' }],
|
||||
defaultActionGroupId: 'default',
|
||||
async executor({ services, params: { instances = DEFAULT_INSTANCES_TO_GENERATE }, state }) {
|
||||
const count = (state.count ?? 0) + 1;
|
||||
|
||||
range(instances)
|
||||
.map(() => ({ id: uuid.v4() }))
|
||||
.forEach((instance: { id: string }) => {
|
||||
services
|
||||
.alertInstanceFactory(instance.id)
|
||||
.replaceState({ triggerdOnCycle: count })
|
||||
.scheduleActions('default');
|
||||
});
|
||||
|
||||
return {
|
||||
count,
|
||||
};
|
||||
},
|
||||
producer: ALERTING_EXAMPLE_APP_ID,
|
||||
};
|
|
@ -1,24 +1,11 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 axios from 'axios';
|
||||
import { AlertType } from '../../../../x-pack/plugins/alerts/server';
|
||||
import { AlertType } from '../../../../plugins/alerts/server';
|
||||
import { Operator, Craft, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
||||
|
||||
interface PeopleInSpace {
|
10
x-pack/examples/alerting_example/server/index.ts
Normal file
10
x-pack/examples/alerting_example/server/index.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* 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 { PluginInitializer } from 'kibana/server';
|
||||
import { AlertingExamplePlugin } from './plugin';
|
||||
|
||||
export const plugin: PluginInitializer<void, void> = () => new AlertingExamplePlugin();
|
|
@ -1,31 +1,18 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* 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 { Plugin, CoreSetup } from 'kibana/server';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { DEFAULT_APP_CATEGORIES } from '../../../src/core/server';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/server';
|
||||
import { PluginSetupContract as FeaturesPluginSetup } from '../../../x-pack/plugins/features/server';
|
||||
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server';
|
||||
import { PluginSetupContract as AlertingSetup } from '../../../plugins/alerts/server';
|
||||
import { PluginSetupContract as FeaturesPluginSetup } from '../../../plugins/features/server';
|
||||
|
||||
import { alertType as alwaysFiringAlert } from './alert_types/always_firing';
|
||||
import { alertType as peopleInSpaceAlert } from './alert_types/astros';
|
||||
import { INDEX_THRESHOLD_ID } from '../../../x-pack/plugins/alerting_builtins/server';
|
||||
import { INDEX_THRESHOLD_ID } from '../../../plugins/alerting_builtins/server';
|
||||
import { ALERTING_EXAMPLE_APP_ID } from '../common/constants';
|
||||
|
||||
// this plugin's dependendencies
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./target"
|
||||
},
|
||||
|
@ -9,10 +9,10 @@
|
|||
"public/**/*.tsx",
|
||||
"server/**/*.ts",
|
||||
"common/**/*.ts",
|
||||
"../../typings/**/*",
|
||||
"../../../typings/**/*",
|
||||
],
|
||||
"exclude": [],
|
||||
"references": [
|
||||
{ "path": "../../src/core/tsconfig.json" }
|
||||
{ "path": "../../../src/core/tsconfig.json" }
|
||||
]
|
||||
}
|
|
@ -18215,7 +18215,6 @@
|
|||
"xpack.triggersActionsUI.typeRegistry.register.duplicateObjectTypeErrorMessage": "オブジェクトタイプ「{id}」は既に登録されています。",
|
||||
"xpack.uiActionsEnhanced.components.actionWizard.changeButton": "変更",
|
||||
"xpack.uiActionsEnhanced.components.actionWizard.insufficientLicenseLevelTooltip": "不十分なライセンスレベル",
|
||||
"xpack.uiActionsEnhanced.components.DiscoverDrilldownConfig.chooseIndexPattern": "対象インデックスパターンを選択",
|
||||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.addToPanelButtonTitle": "パネルに追加",
|
||||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.cancelButtonTitle": "キャンセル",
|
||||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.optionsMenuForm.panelTitleFormRowLabel": "時間範囲",
|
||||
|
@ -18223,7 +18222,6 @@
|
|||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.updatePanelTimeRangeButtonTitle": "更新",
|
||||
"xpack.uiActionsEnhanced.customizeTimeRange.modal.headerTitle": "パネルの時間範囲のカスタマイズ",
|
||||
"xpack.uiActionsEnhanced.customizeTimeRangeMenuItem.displayName": "時間範囲のカスタマイズ",
|
||||
"xpack.uiActionsEnhanced.drilldown.goToDiscover": "Discoverに移動(例)",
|
||||
"xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.helpText": "ドリルダウンにより、パネルと連携する新しい動作を定義できます。複数のアクションを追加し、デフォルトフィルターを無効化できます。",
|
||||
"xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel": "非表示",
|
||||
"xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel": "ドキュメントを表示",
|
||||
|
|
|
@ -18226,7 +18226,6 @@
|
|||
"xpack.triggersActionsUI.typeRegistry.register.duplicateObjectTypeErrorMessage": "已注册对象类型“{id}”。",
|
||||
"xpack.uiActionsEnhanced.components.actionWizard.changeButton": "更改",
|
||||
"xpack.uiActionsEnhanced.components.actionWizard.insufficientLicenseLevelTooltip": "许可证级别不够",
|
||||
"xpack.uiActionsEnhanced.components.DiscoverDrilldownConfig.chooseIndexPattern": "选择目标索引模式",
|
||||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.addToPanelButtonTitle": "添加到面板",
|
||||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.cancelButtonTitle": "取消",
|
||||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.optionsMenuForm.panelTitleFormRowLabel": "时间范围",
|
||||
|
@ -18234,7 +18233,6 @@
|
|||
"xpack.uiActionsEnhanced.customizePanelTimeRange.modal.updatePanelTimeRangeButtonTitle": "更新",
|
||||
"xpack.uiActionsEnhanced.customizeTimeRange.modal.headerTitle": "定制面板时间范围",
|
||||
"xpack.uiActionsEnhanced.customizeTimeRangeMenuItem.displayName": "定制时间范围",
|
||||
"xpack.uiActionsEnhanced.drilldown.goToDiscover": "前往 Discover(示例)",
|
||||
"xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.helpText": "向下钻取允许您定义与面板交互的新行为。您可以添加多个操作并覆盖默认筛选。",
|
||||
"xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel": "隐藏",
|
||||
"xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel": "查看文档",
|
||||
|
|
Loading…
Reference in a new issue