This PR encourages type safe usage of the Alerting framework by replacing the current default Params/State/InstanceState/InstanceContext types (which are `AlertTypeParams`/`AlertTypeState`/etc.) with `never`. This means that code can continue to omit the specific types for these fields, as long as they aren't referenced. Once an alert developer wishes to actually reference the parameters (or state/context), then they have to specify the type. This PR also changed the typing of the `AlertTypeParams` and `AlertTypeState` from `Record<string, any>` to `Record<string, unknown>`, to ensure that where these catch-all types are used they will at least enforce `unknown` rather than `any`. This change broke some usage in both @elastic/kibana-alerting-services plugins, but also other plugins in the Stack/Solutions. I tried to fix these where I could, but some of these require new types and refactoring in other teams' code, which I decided is best done by the team who own and maintain that code - I've added explicit `TODO` comments in all of these places, describing the required fix. This PR also introduced a Generics based typing for the `Alert` type so that the `params` field can be typed as something other than `AlertTypeParams`. |
||
---|---|---|
.. | ||
common | ||
public | ||
server | ||
jest.config.js | ||
kibana.json | ||
README.md |
stack_alerts plugin
This plugin provides alertTypes shipped with Kibana for use with the the alerts plugin. When enabled, it will register the alertTypes by the Stack in the alerting plugin, register associated HTTP routes, etc.
The plugin setup
and start
contracts for this plugin are the following
type, which provides some runtime capabilities. Each built-in alertType will
have it's own top-level property in the IService
interface, if it needs to
expose functionality.
export interface IService {
indexThreshold: {
timeSeriesQuery(params: TimeSeriesQueryParameters): Promise<TimeSeriesResult>;
}
}
Each Stack AlertType is described in it's own README:
- index threshold:
server/alert_types/index_threshold