-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Registering all rule types with alerting and conditionally having fra…
…mework install context specific resources
- Loading branch information
Showing
64 changed files
with
1,390 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/kbn-alerts-as-data-utils/src/field_maps/legacy_experimental_field_map.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { ALERT_EVALUATION_THRESHOLD, ALERT_EVALUATION_VALUE } from '@kbn/rule-data-utils'; | ||
|
||
export const legacyExperimentalFieldMap = { | ||
[ALERT_EVALUATION_THRESHOLD]: { | ||
type: 'scaled_float', | ||
scaling_factor: 100, | ||
required: false, | ||
}, | ||
[ALERT_EVALUATION_VALUE]: { type: 'scaled_float', scaling_factor: 100, required: false }, | ||
} as const; | ||
|
||
export type ExperimentalRuleFieldMap = typeof legacyExperimentalFieldMap; |
79 changes: 79 additions & 0 deletions
79
...plugins/alerting/common/alert_schema/field_maps/component_template_from_field_map.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* 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 { getComponentTemplateFromFieldMap } from './component_template_from_field_map'; | ||
import { testFieldMap, expectedTestMapping } from './mapping_from_field_map.test'; | ||
|
||
describe('getComponentTemplateFromFieldMap', () => { | ||
it('correctly creates component template from field map', () => { | ||
expect( | ||
getComponentTemplateFromFieldMap({ name: 'test-mappings', fieldMap: testFieldMap }) | ||
).toEqual({ | ||
name: 'test-mappings', | ||
_meta: { | ||
managed: true, | ||
}, | ||
template: { | ||
settings: {}, | ||
mappings: { | ||
dynamic: 'strict', | ||
...expectedTestMapping, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('correctly creates component template with settings when includeSettings = true', () => { | ||
expect( | ||
getComponentTemplateFromFieldMap({ | ||
name: 'test-mappings', | ||
fieldMap: testFieldMap, | ||
includeSettings: true, | ||
}) | ||
).toEqual({ | ||
name: 'test-mappings', | ||
_meta: { | ||
managed: true, | ||
}, | ||
template: { | ||
settings: { | ||
number_of_shards: 1, | ||
'index.mapping.total_fields.limit': 1500, | ||
}, | ||
mappings: { | ||
dynamic: 'strict', | ||
...expectedTestMapping, | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('correctly creates component template with dynamic setting when defined', () => { | ||
expect( | ||
getComponentTemplateFromFieldMap({ | ||
name: 'test-mappings', | ||
fieldMap: testFieldMap, | ||
includeSettings: true, | ||
dynamic: false, | ||
}) | ||
).toEqual({ | ||
name: 'test-mappings', | ||
_meta: { | ||
managed: true, | ||
}, | ||
template: { | ||
settings: { | ||
number_of_shards: 1, | ||
'index.mapping.total_fields.limit': 1500, | ||
}, | ||
mappings: { | ||
dynamic: false, | ||
...expectedTestMapping, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.