Skip to content

Commit

Permalink
[maps][geo containment alert] fix boundaries are not re-fetched when …
Browse files Browse the repository at this point in the history
…query changes (#157408)

Fixes #157068 and
#157066

<img width="800" alt="Screen Shot 2023-05-11 at 10 16 31 AM"
src="https://github.com/elastic/kibana/assets/373691/3ee3b573-f3f9-497f-afef-1927f43681a7">

Throwing errors provides better user feedback when alerting rules
encounter problems. PR updates tracking containment rule to throw when:
* No tracking containment boundaries are found. Prior to this PR, entity
containment search request would throw because "filters" was undefined.
Root cause of #157068
* Throw when entity containment search request throws. Prior to this PR,
entity containment search request failure was just logged as server
warning.

PR updates boundaries cache to refresh whenever any parameters change
that result in boundary filters needing to be updated, resolving
#157066

PR defines common type "RegisterRuleTypesParams" for
registerBuiltInRuleTypes parameter to avoid duplicate type definitions
for the same thing.

PR also cleans up some tech debt in tracking containment rule
* "alert" name replaced with "rule" some time ago. PR renames
"alert_type" to "rule_type".
* Breaks types defined in "alert_type" into separate "types" file
* Breaks "geoContainment.ts" and "geoContainment.test.ts" files into
separate files, "executor.ts", "lib/get_entities_and_generate_alerts",
and "lib/transform_results.ts"
* Renames type "GeoContainmentParams" to "GeoContainmentRuleParams"
* Renames type "GeoContainmentExtractedParams" to
"GeoContainmentExtractedRuleParams"
* Renames type "GeoContainmentState" to "GeoContainmentRuleState"
* Renames type "GeoContainmentInstanceState" to
"GeoContainmentAlertInstanceState"
* Renames type "GeoContainmentInstanceContext" to
"GeoContainmentAlertInstanceContext"
* Renames type "GeoContainmentAlertType" to "GeoContainmentRuleType"

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Nick Peihl <nickpeihl@gmail.com>
  • Loading branch information
3 people authored and jasonrhodes committed May 17, 2023
1 parent 2030b0c commit a1a4a12
Show file tree
Hide file tree
Showing 29 changed files with 1,604 additions and 1,635 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/stack_alerts/server/feature.ts
Expand Up @@ -10,7 +10,7 @@ import { KibanaFeatureConfig } from '@kbn/features-plugin/common';
import { DEFAULT_APP_CATEGORIES } from '@kbn/core/server';
import { TRANSFORM_RULE_TYPE } from '@kbn/transform-plugin/common';
import { ID as IndexThreshold } from './rule_types/index_threshold/rule_type';
import { GEO_CONTAINMENT_ID as GeoContainment } from './rule_types/geo_containment/alert_type';
import { GEO_CONTAINMENT_ID as GeoContainment } from './rule_types/geo_containment';
import { ES_QUERY_ID as ElasticsearchQuery } from './rule_types/es_query/constants';
import { STACK_ALERTS_FEATURE_ID } from '../common';

Expand Down
10 changes: 2 additions & 8 deletions x-pack/plugins/stack_alerts/server/rule_types/es_query/index.ts
Expand Up @@ -5,16 +5,10 @@
* 2.0.
*/

import { CoreSetup } from '@kbn/core/server';
import { AlertingSetup } from '../../types';
import type { RegisterRuleTypesParams } from '../types';
import { getRuleType } from './rule_type';

interface RegisterParams {
alerting: AlertingSetup;
core: CoreSetup;
}

export function register(params: RegisterParams) {
export function register(params: RegisterRuleTypesParams) {
const { alerting, core } = params;
alerting.registerType(getRuleType(core));
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,11 @@
/*
* 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.
*/

export const ActionGroupId = 'Tracked entity contained';
export const RecoveryActionGroupId = 'notGeoContained';
export const GEO_CONTAINMENT_ID = '.geo-containment';
export const OTHER_CATEGORY = 'other';

This file was deleted.

0 comments on commit a1a4a12

Please sign in to comment.