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

Introduce geo-threshold alerts #76285

Merged
merged 92 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
d9feaf8
Sample server set up
Jul 6, 2020
5e04cb5
Merge remote-tracking branch 'upstream/master' into maps-alerts
Jul 9, 2020
7b1e63a
Merge remote-tracking branch 'upstream/master' into maps-alerts
Jul 13, 2020
7fd2e12
Front end producing fly out panel launched from top nav
Jul 17, 2020
3aee55d
Merge remote-tracking branch 'upstream/master' into maps-alerts
Jul 31, 2020
6498731
Add index threshold to maps
Aug 3, 2020
b240f26
Clean up
Aug 3, 2020
15df0e8
Executor creates and makes agg query w/ switch for different shape types
Aug 5, 2020
150f386
Alerts working in initial tests
Aug 13, 2020
a8361ae
Merge remote-tracking branch 'upstream/master' into maps-alerts
Aug 13, 2020
03d16b4
Merge remote-tracking branch 'upstream/master' into maps-alerts
Aug 14, 2020
ca57405
Geo threshold UI started with some major pieces in place. Back-end st…
Aug 18, 2020
ae7f61e
UI working without validation
Aug 25, 2020
a092358
Merge remote-tracking branch 'upstream/master' into maps-alerts
Aug 25, 2020
c0bf66d
Move back-end logic to alerts built-ins
Aug 31, 2020
7df4d2e
Merge remote-tracking branch 'upstream/master' into maps-alerts
Aug 31, 2020
a1733a1
Clean up maps mods
Aug 31, 2020
13d82da
Add schema validation. Clean up unused logic on back end
Aug 31, 2020
0b38bdb
Revise queries and comparison logic to handle movements within shapes…
Sep 2, 2020
01f6964
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 2, 2020
cb93339
Remove old files from early tests
Sep 3, 2020
76dc00a
Add geofield to query
Sep 4, 2020
c173ee9
Make date field part of query dynamic
Sep 4, 2020
77f1e3e
Update code to account for dynamic date. Also grab location data to p…
Sep 4, 2020
944a4f8
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 4, 2020
078d781
Update two missed refs to date and location
Sep 4, 2020
16400eb
Select an index -> Select entity
Sep 4, 2020
97bec60
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 10, 2020
1f46fd6
Add context variables for better connector tracking
Sep 14, 2020
61e705c
Update sorting in both query and lodash handling
Sep 14, 2020
a167988
Track id of crossing entity
Sep 14, 2020
8943656
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 15, 2020
1f95cef
Capture index pattern id and title in UI
Sep 15, 2020
093be29
Correctly show invalid entries
Sep 15, 2020
fafc8b6
Add alert params create validation
Sep 16, 2020
51da2b1
i18n fixes and clean up
Sep 16, 2020
aba7e31
Fix jest test error
Sep 16, 2020
6443b61
Linting errors
Sep 16, 2020
1dfbcce
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 16, 2020
d4cfe77
Finish updates to passed args index title and id
Sep 16, 2020
4374310
Remove unused data plugin ref
Sep 16, 2020
44d756e
Review feedback. Set condition to 'entered' for review. Only allow nu…
Sep 17, 2020
d2ae160
Clean up typing errors & some general clean up
Sep 18, 2020
58d9cbd
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 18, 2020
83781f2
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 21, 2020
a50ecb9
More type updates
Sep 22, 2020
ba16694
Review feedback. Update param names, logging, some clean up
Sep 22, 2020
83f0c6d
Review feedback. Re-enable 'exited'. Add 'ip' field to possible entit…
Sep 22, 2020
afed143
Call large query on first run only, carry previous results through state
Sep 23, 2020
6ebd455
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 23, 2020
db523c2
Get filter shapes only once initially then pull from state
Sep 24, 2020
130e617
Use human-readable boundary name for alert instance if avab. or fall …
Sep 24, 2020
036a46b
Type fixes
Sep 24, 2020
2f77334
Update order of args in call to getShapesFilters
Sep 24, 2020
68e9414
Set boundaryNameField optional in interface
Sep 24, 2020
79971f8
Types clean up
Sep 24, 2020
76e699a
Only show entering option (for review)
Sep 24, 2020
49652bd
Add server side jest tests for validation and geo threshold transform…
Sep 29, 2020
e1af8a3
Add client side validation tests
Sep 29, 2020
beca47b
Merge remote-tracking branch 'upstream/master' into maps-alerts
Sep 29, 2020
e4e6fa9
i18n fix
Sep 29, 2020
e139fd4
Review feedback. Add linestring context value, clean up types, genera…
Sep 29, 2020
f0491bd
Fix jest test issue, lodash get missing object
Sep 29, 2020
50e0926
Review feedback. Update context variables
Sep 30, 2020
da52a2c
i18n fix
Sep 30, 2020
45eee57
Reset index-related fields on change
Sep 30, 2020
5add92c
Only include geo_point for tracking index
Sep 30, 2020
997e0f2
Only use geo_shapes for boundaries
Sep 30, 2020
fc8090b
Update snapshot
Sep 30, 2020
a91c3ac
Allow user to select nothing on boundary name
Sep 30, 2020
87116fa
Clean up and type updates
Sep 30, 2020
8f346d3
Pre-populate index & boundary index related fields with first options
Sep 30, 2020
604d107
Auto-populate category based upon index selected
Sep 30, 2020
035714b
Type updates
Sep 30, 2020
84513c8
Code the geo fields as wkt
Sep 30, 2020
05cac9e
Fix wkt spacing
Oct 1, 2020
c5a9323
Remove temp testing logic
Oct 1, 2020
30aad87
Add limited time window to first run
Oct 1, 2020
832ddd4
Type updates
Oct 1, 2020
e2a305f
Merge remote-tracking branch 'upstream/master' into maps-alerts
Oct 1, 2020
b9d75bd
Add delay offset
Oct 2, 2020
523de58
Handle sorting manually vs. using lodash
Oct 2, 2020
a84b78f
Set sub agg query size to max 10k. Fixes issue where points in 'other…
Oct 3, 2020
bc5d4d1
Don't clobber previously defined entity with auto-complete on alert edit
Oct 3, 2020
ecbac9e
Fall back to 'boundaryId' from 'fromBoundaryName' if human-readable n…
Oct 3, 2020
e3c053d
Review feedback. Type updates, clean up, i18n changes
Oct 3, 2020
8dbc8a4
Review feedback. ES query const tweaks
Oct 4, 2020
d2ca92c
Add barebones server to triggers_actions_ui and connect config up thr…
Oct 4, 2020
1acdf69
Type fixes
Oct 4, 2020
9e08608
Merge remote-tracking branch 'upstream/master' into maps-alerts
Oct 4, 2020
64dd8d5
Merge remote-tracking branch 'upstream/master' into maps-alerts
Oct 5, 2020
19ff93f
Review feedback. Remove unneeded colons in UI
Oct 5, 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
Prev Previous commit
Next Next commit
Add client side validation tests
  • Loading branch information
Aaron Caldwell committed Sep 29, 2020
commit e1af8a3df8309bd71c83ba781fe596f5f568caba
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* 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 { GeoThresholdAlertParams } from './types';
import { validateExpression } from './validation';

describe('expression params validation', () => {
test('if index property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: '',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.index.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.index[0]).toBe('Index pattern is required.');
});

test('if geoField property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: '',
entity: 'testField',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.geoField.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.geoField[0]).toBe('Geo field is required.');
});

test('if entity property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: '',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.entity.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.entity[0]).toBe('Entity is required.');
});

test('if dateField property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: '',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.dateField.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.dateField[0]).toBe('Date field is required.');
});

test('if trackingEvent property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: 'testField',
trackingEvent: '',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.trackingEvent.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.trackingEvent[0]).toBe(
'Tracking event is required.'
);
});

test('if boundaryType property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: '',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.boundaryType.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.boundaryType[0]).toBe(
'Boundary type is required.'
);
});

test('if boundaryIndexTitle property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: '',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
};
expect(validateExpression(initialParams).errors.boundaryIndexTitle.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.boundaryIndexTitle[0]).toBe(
'Boundary index pattern title is required.'
);
});

test('if boundaryGeoField property is invalid should return proper error message', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: '',
};
expect(validateExpression(initialParams).errors.boundaryGeoField.length).toBeGreaterThan(0);
expect(validateExpression(initialParams).errors.boundaryGeoField[0]).toBe(
'Boundary geo field is required.'
);
});

test('if boundaryNameField property is missing should not return error', () => {
const initialParams: GeoThresholdAlertParams = {
index: 'testIndex',
indexId: 'testIndexId',
geoField: 'testField',
entity: 'testField',
dateField: 'testField',
trackingEvent: 'testEvent',
boundaryType: 'testType',
boundaryIndexTitle: 'testIndex',
boundaryIndexId: 'testIndexId',
boundaryGeoField: 'testField',
boundaryNameField: '',
};
expect(validateExpression(initialParams).errors.boundaryGeoField.length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const validateExpression = (alertParams: GeoThresholdAlertParams): Valida
if (!index) {
errors.index.push(
i18n.translate('xpack.triggersActionsUI.geoThreshold.error.requiredIndexTitleText', {
defaultMessage: 'Index pattern title is required.',
defaultMessage: 'Index pattern is required.',
})
);
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export const validateExpression = (alertParams: GeoThresholdAlertParams): Valida
if (!boundaryType) {
errors.boundaryType.push(
i18n.translate('xpack.triggersActionsUI.geoThreshold.error.requiredTrackingEventText', {
defaultMessage: 'Tracking event is required.',
defaultMessage: 'Boundary type is required.',
})
);
}
Expand Down