Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Add Alerting UI #57919

Merged
merged 120 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
8f43e13
WIP trying things.
justinkambic Jan 28, 2020
4778670
Port adapter function to dedicated file.
justinkambic Feb 5, 2020
724fea8
WIP.
justinkambic Feb 10, 2020
3f17b51
Working on parameter selection.
justinkambic Feb 10, 2020
b62d15b
Selector expressions working.
justinkambic Feb 12, 2020
5814074
Working on actions.
justinkambic Feb 13, 2020
99abd50
Change anchor prop for popovers.
justinkambic Feb 14, 2020
8e07e73
Reference migrated alerting plugin.
justinkambic Feb 18, 2020
92ff59d
Clean up code for draft.
justinkambic Feb 18, 2020
7adcfc4
Add button to expose flyout. Clean up some client code.
justinkambic Feb 19, 2020
33ca971
Add test for requests function, add support for filters.
justinkambic Feb 20, 2020
9ec182f
Reorganize and clean up files.
justinkambic Feb 21, 2020
06fe939
Add location and filter support to monitor status request function.
justinkambic Feb 21, 2020
5302078
Add tests for monitor status request function.
justinkambic Feb 21, 2020
103cb46
Specify default action group id in alert registration.
justinkambic Feb 25, 2020
b9eb062
Extract repeated string value to a constant.
justinkambic Feb 25, 2020
e2c9429
Move test file to server in NP plugin.
justinkambic Feb 25, 2020
adfe4c9
Update imports after NP migration.
justinkambic Feb 25, 2020
c465503
Fix UI bug that caused incorrect location selections in alert creation.
justinkambic Feb 25, 2020
8e21ba7
Change alert expression language to clarify meaning.
justinkambic Feb 26, 2020
96befca
Add ability for user to select timerange units.
justinkambic Feb 26, 2020
fc9e349
Add code that fixes active item highlighting.
justinkambic Feb 27, 2020
babf36f
Add better default value for active index selection.
justinkambic Feb 27, 2020
57c0115
Introduce dedicated field number component.
justinkambic Feb 27, 2020
714d571
Add message to status check alert.
justinkambic Feb 28, 2020
7c6124a
Add tests for context message.
justinkambic Feb 28, 2020
41252e8
Formalize alert action group definitions.
justinkambic Feb 28, 2020
06fcfc2
Extract monitor id squashing from context message generator.
justinkambic Feb 28, 2020
ec5c65d
Write test for monitor ID uniqueness function.
justinkambic Feb 28, 2020
f16265b
Add alert state creator function and tests.
justinkambic Feb 29, 2020
91cc166
Update action group id value.
justinkambic Mar 2, 2020
51903c5
Add tests for alert factory and executor function.
justinkambic Mar 2, 2020
883982d
Rename alert context props to be more domain-specific.
justinkambic Mar 2, 2020
02ad172
Clean up unnecessary type markup.
justinkambic Mar 2, 2020
7e1334d
Clean up alert ui controls file.
justinkambic Mar 2, 2020
7066560
Better organize new registration code.
justinkambic Mar 2, 2020
5c1e2ce
Simplify some logic code.
justinkambic Mar 3, 2020
eaf5096
Clean up bootstrap code.
justinkambic Mar 3, 2020
b1cf040
Add unit tests for alert type.
justinkambic Mar 3, 2020
eefe631
Delete temporary test code from triggers_actions_ui.
justinkambic Mar 3, 2020
4b10372
Rename a test file.
justinkambic Mar 3, 2020
2b3b01d
Add some comments to annotate a file.
justinkambic Mar 3, 2020
47e4a52
Add io-ts type checking to alert create validation and alert executor.
justinkambic Mar 3, 2020
a15d33f
Add translation of plaintext content string.
justinkambic Mar 3, 2020
d40f65c
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 3, 2020
6ef25fc
Further simplify monitor status alert validation.
justinkambic Mar 3, 2020
56b8d8f
Add io-ts type checking to alert params.
justinkambic Mar 3, 2020
0b94255
Update a comment.
justinkambic Mar 3, 2020
5e9a258
Prefer inline snapshots to more error-prone assertions.
justinkambic Mar 3, 2020
f4e5247
Clean up and comment request function.
justinkambic Mar 4, 2020
c3dd218
Rename a symbol.
justinkambic Mar 4, 2020
e0800b6
Fix broken types in reducer file and add a test.
justinkambic Mar 4, 2020
e67a7a1
Fix a validation logic error and add tests.
justinkambic Mar 4, 2020
469abe7
Delete unused import.
justinkambic Mar 4, 2020
687546d
Delete obsolete dependency.
justinkambic Mar 4, 2020
5a83c95
Fix function call to have correct parameters.
justinkambic Mar 4, 2020
100fc0b
Fixing some import weirdness.
justinkambic Mar 4, 2020
373dfb7
Reintroduce accidentally-deleted code.
justinkambic Mar 4, 2020
3fec4b5
Delete unneeded require from legacy entry file.
justinkambic Mar 5, 2020
d1df7ca
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 5, 2020
40f1789
Remove unneeded connected component.
justinkambic Mar 5, 2020
a736b8b
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 5, 2020
f6efd0d
Update flyout controls for new interface and delete connected compone…
justinkambic Mar 5, 2020
e592846
Remove unneeded require from app index file.
justinkambic Mar 6, 2020
7b144e4
Introduce data-test-subj attributes to various components to assist w…
justinkambic Mar 6, 2020
3825b33
Introduce functional test helpers for alert flyout.
justinkambic Mar 6, 2020
dc9a468
Add functional test arch and a test for alerting UI to ES SSL test su…
justinkambic Mar 6, 2020
645b7d1
Add explicit exports to module index.
justinkambic Mar 6, 2020
eaa4d19
Reorganize file to keep interfaces closer to their implementations.
justinkambic Mar 6, 2020
cb6bde1
Move create alert button to better position.
justinkambic Mar 9, 2020
7136922
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 9, 2020
3865f0e
Clean up a file.
justinkambic Mar 9, 2020
c88e5a9
Update a functional test attribute, clean up a file, rename a selecto…
justinkambic Mar 9, 2020
8681a5d
Add a comment.
justinkambic Mar 9, 2020
eaf6771
Make better default alert message, translate messages, add/update tests.
justinkambic Mar 9, 2020
90bdf9a
Fix broken type.
justinkambic Mar 10, 2020
ca51e87
Update obsolete snapshot.
justinkambic Mar 10, 2020
2f3f524
Introduce mock provider to tests and update snapshots.
justinkambic Mar 10, 2020
86f0712
Reduce a strange type to `any`.
justinkambic Mar 10, 2020
7d888a2
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 10, 2020
10f1ff7
Add alert flyout button connected component.
justinkambic Mar 10, 2020
420eac8
Add alert flyout wrapper connected component.
justinkambic Mar 10, 2020
6d40608
Create connected component for alert monitor status alert.
justinkambic Mar 10, 2020
93516e1
Clean up index files.
justinkambic Mar 10, 2020
150a07c
Update i18nrc file to cover translation in server plugin code.
justinkambic Mar 10, 2020
ec342ba
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 11, 2020
c9244bc
Fix broken imports.
justinkambic Mar 11, 2020
bba9c7c
Update test snapshots.
justinkambic Mar 11, 2020
0740913
Merge branch 'master' into uptime_alerting-ui
elasticmachine Mar 11, 2020
671b5ed
Prefer more descriptive type.
justinkambic Mar 13, 2020
5d597e4
Merge branch 'uptime_alerting-ui' of github.com:justinkambic/kibana i…
justinkambic Mar 13, 2020
ca1de1a
Prefer more descriptive type.
justinkambic Mar 13, 2020
5884832
Prefer built-in React propType to custom.
justinkambic Mar 13, 2020
6584d3f
Prefer simpler validation.
justinkambic Mar 13, 2020
c205f6f
Add whitespace to clean up file.
justinkambic Mar 13, 2020
62ed1c6
Extract function and write tests.
justinkambic Mar 13, 2020
1946435
Simplify validation function.
justinkambic Mar 13, 2020
65ccd47
Add navigate to alerting button.
justinkambic Mar 16, 2020
3de3932
Move context item inside the items list.
justinkambic Mar 16, 2020
c73de94
Clean up alert creation component.
justinkambic Mar 16, 2020
25c8068
Update type check parsing and error messaging, and update snapshot/te…
justinkambic Mar 16, 2020
ef3f3e7
Update broken snapshot.
justinkambic Mar 16, 2020
49162bd
Update README for running functional tests.
justinkambic Mar 16, 2020
605cee8
Update functional test service to reflect improved UX.
justinkambic Mar 16, 2020
4e0b9b4
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 16, 2020
e444618
Fix broken type that resulted from a mistake during a merge resolution.
justinkambic Mar 17, 2020
ef6b687
Add spacer between alert title and kuery bar.
justinkambic Mar 17, 2020
e482f08
Update the id and name of our alert type because it was never changed…
justinkambic Mar 17, 2020
ab40de8
Rename alert keys.
justinkambic Mar 17, 2020
42a3a5d
Fix broken unit tests.
justinkambic Mar 17, 2020
65e6519
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 17, 2020
f0066db
Merge branch 'master' into uptime_alerting-ui
elasticmachine Mar 18, 2020
04c5fff
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 18, 2020
d7d8905
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 18, 2020
74006e2
Add aria-labels to alert UI.
justinkambic Mar 18, 2020
2519a8c
Implement design feedback.
justinkambic Mar 18, 2020
7034654
Merge branch 'master' into uptime_alerting-ui
justinkambic Mar 18, 2020
7006288
Fix broken test snapshots.
justinkambic Mar 18, 2020
d1e3d19
Add missing props to unit tests to staisfy updated types.
justinkambic Mar 18, 2020
4329fc6
Merge branch 'master' into uptime_alerting-ui
elasticmachine Mar 19, 2020
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
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"xpack.transform": "plugins/transform",
"xpack.triggersActionsUI": "plugins/triggers_actions_ui",
"xpack.upgradeAssistant": "plugins/upgrade_assistant",
"xpack.uptime": "legacy/plugins/uptime",
"xpack.uptime": ["plugins/uptime", "legacy/plugins/uptime"],
"xpack.watcher": "plugins/watcher"
},
"translations": [
Expand Down
10 changes: 10 additions & 0 deletions x-pack/legacy/plugins/uptime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ You can login with username `elastic` and password `changeme` by default.

If you want to freeze a UI or API test you can include an async call like `await new Promise(r => setTimeout(r, 1000 * 60))`
to freeze the execution for 60 seconds if you need to click around or check things in the state that is loaded.

#### Running --ssl tests

Some of our tests require there to be an SSL connection between Kibana and Elasticsearch.

We can run these tests like described above, but with some special config.

`node scripts/functional_tests_server.js --config=test/functional_with_es_ssl/config.ts`

`node scripts/functional_test_runner.js --config=test/functional_with_es_ssl/config.ts`
Comment on lines +65 to +74
Copy link
Contributor

Choose a reason for hiding this comment

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

very helfpul.

19 changes: 19 additions & 0 deletions x-pack/legacy/plugins/uptime/common/constants/alerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.
*/

interface ActionGroupDefinition {
id: string;
name: string;
}

type ActionGroupDefinitions = Record<string, ActionGroupDefinition>;

export const ACTION_GROUP_DEFINITIONS: ActionGroupDefinitions = {
MONITOR_STATUS: {
id: 'xpack.uptime.alerts.actionGroups.monitorStatus',
name: 'Uptime Down Monitor',
},
};
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/uptime/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { ACTION_GROUP_DEFINITIONS } from './alerts';
export { CHART_FORMAT_LIMITS } from './chart_format_limits';
export { CLIENT_DEFAULTS } from './client_defaults';
export { CONTEXT_DEFAULTS } from './context_defaults';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

export const INDEX_NAMES = {
HEARTBEAT: 'heartbeat-8*',
HEARTBEAT_STATES: 'heartbeat-states-8*',
};
12 changes: 12 additions & 0 deletions x-pack/legacy/plugins/uptime/common/runtime_types/alerts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 {
StatusCheckAlertStateType,
StatusCheckAlertState,
StatusCheckExecutorParamsType,
StatusCheckExecutorParams,
} from './status_check';
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 * as t from 'io-ts';

export const StatusCheckAlertStateType = t.intersection([
t.partial({
currentTriggerStarted: t.string,
firstTriggeredAt: t.string,
lastTriggeredAt: t.string,
lastResolvedAt: t.string,
}),
t.type({
firstCheckedAt: t.string,
lastCheckedAt: t.string,
isTriggered: t.boolean,
}),
]);

export type StatusCheckAlertState = t.TypeOf<typeof StatusCheckAlertStateType>;

export const StatusCheckExecutorParamsType = t.intersection([
t.partial({
filters: t.string,
}),
t.type({
locations: t.array(t.string),
numTimes: t.number,
timerange: t.type({
from: t.string,
to: t.string,
}),
}),
]);

export type StatusCheckExecutorParams = t.TypeOf<typeof StatusCheckExecutorParamsType>;
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/uptime/common/runtime_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export * from './alerts';
export * from './common';
export * from './monitor';
export * from './overview_filters';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/uptime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const uptime = (kibana: any) =>
configPrefix: 'xpack.uptime',
id: PLUGIN.ID,
publicDir: resolve(__dirname, 'public'),
require: ['kibana', 'elasticsearch', 'xpack_main'],
require: ['alerting', 'kibana', 'elasticsearch', 'xpack_main'],
uiExports: {
app: {
description: i18n.translate('xpack.uptime.pluginDescription', {
Expand Down
5 changes: 3 additions & 2 deletions x-pack/legacy/plugins/uptime/public/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { npSetup } from 'ui/new_platform';
import { Plugin } from './plugin';
import 'uiExports/embeddableFactories';

new Plugin({
const plugin = new Plugin({
opaqueId: Symbol('uptime'),
env: {} as any,
config: { get: () => ({} as any) },
}).setup(npSetup);
});
plugin.setup(npSetup);
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/uptime/public/apps/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class Plugin {
public setup(setup: SetupObject) {
const { core, plugins } = setup;
const { home } = plugins;

home.featureCatalogue.register({
category: FeatureCatalogueCategory.DATA,
description: PLUGIN.DESCRIPTION,
Expand All @@ -45,6 +46,7 @@ export class Plugin {
showOnHomePage: true,
title: PLUGIN.TITLE,
});

core.application.register({
id: PLUGIN.ID,
euiIconType: 'uptimeApp',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 { useSelector } from 'react-redux';
import { DataPublicPluginSetup } from 'src/plugins/data/public';
import { selectMonitorStatusAlert } from '../../../state/selectors';
import { AlertMonitorStatusComponent } from '../../functional/alerts/alert_monitor_status';

interface Props {
autocomplete: DataPublicPluginSetup['autocomplete'];
enabled: boolean;
numTimes: number;
setAlertParams: (key: string, value: any) => void;
timerange: {
from: string;
to: string;
};
}

export const AlertMonitorStatus = ({
autocomplete,
enabled,
numTimes,
setAlertParams,
timerange,
}: Props) => {
const { filters, locations } = useSelector(selectMonitorStatusAlert);
return (
<AlertMonitorStatusComponent
autocomplete={autocomplete}
enabled={enabled}
filters={filters}
locations={locations}
numTimes={numTimes}
setAlertParams={setAlertParams}
timerange={timerange}
/>
);
};
Original file line number Diff line number Diff line change
@@ -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.
*/

export { AlertMonitorStatus } from './alert_monitor_status';
export { ToggleAlertFlyoutButton } from './toggle_alert_flyout_button';
export { UptimeAlertsFlyoutWrapper } from './uptime_alerts_flyout_wrapper';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 { useDispatch } from 'react-redux';
import { ToggleAlertFlyoutButtonComponent } from '../../functional';
import { setAlertFlyoutVisible } from '../../../state/actions';

export const ToggleAlertFlyoutButton = () => {
const dispatch = useDispatch();
return (
<ToggleAlertFlyoutButtonComponent
setAlertFlyoutVisible={(value: boolean) => dispatch(setAlertFlyoutVisible(value))}
/>
);
};
Original file line number Diff line number Diff line change
@@ -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 React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { UptimeAlertsFlyoutWrapperComponent } from '../../functional';
import { setAlertFlyoutVisible } from '../../../state/actions';
import { selectAlertFlyoutVisibility } from '../../../state/selectors';

interface Props {
alertTypeId?: string;
canChangeTrigger?: boolean;
}

export const UptimeAlertsFlyoutWrapper = ({ alertTypeId, canChangeTrigger }: Props) => {
const dispatch = useDispatch();
const setAddFlyoutVisiblity = (value: React.SetStateAction<boolean>) =>
// @ts-ignore the value here is a boolean, and it works with the action creator function
dispatch(setAlertFlyoutVisible(value));

const alertFlyoutVisible = useSelector(selectAlertFlyoutVisibility);

return (
<UptimeAlertsFlyoutWrapperComponent
alertFlyoutVisible={alertFlyoutVisible}
alertTypeId={alertTypeId}
canChangeTrigger={canChangeTrigger}
setAlertFlyoutVisibility={setAddFlyoutVisiblity}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { AlertMonitorStatus, ToggleAlertFlyoutButton, UptimeAlertsFlyoutWrapper } from './alerts';
export { PingHistogram } from './charts/ping_histogram';
export { Snapshot } from './charts/snapshot_container';
export { KueryBar } from './kuerybar/kuery_bar_container';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { connect } from 'react-redux';
import { AppState } from '../../../state';
import { selectIndexPattern } from '../../../state/selectors';
import { getIndexPattern } from '../../../state/actions';
import { KueryBarComponent } from '../../functional';
import { KueryBarComponent } from '../../functional/kuery_bar/kuery_bar';

const mapStateToProps = (state: AppState) => ({ ...selectIndexPattern(state) });

Expand Down
Loading