* [Alerts][License] Define minimum license required for each alert type (#84997) * Define minimum license required for each alert type * fixed typechecks * fixed tests * fixed tests * fixed due to comments * fixed due to comments * removed file * removed casting to LicenseType * [Alerts][License] Add license checks to alerts HTTP APIs and execution (#85223) * [Alerts][License] Add license checks to alerts HTTP APIs and execution * fixed typechecks * resolved conflicts * resolved conflicts * added router tests * fixed typechecks * added license check support for alert task running * fixed typechecks * added integration tests * fixed due to comments * fixed due to comments * fixed tests * fixed typechecks * [Alerting UI][License] Disable alert types in UI when the license doesn't support it. (#85496) * [Alerting UI][License] Disable alert types in UI when the license doesn't support it. * fixed typechecks * added licensing for alert list and details page * fixed multy select menu * fixed due to comments * fixed due to comments * fixed due to comments * fixed typechecks * fixed license error message * fixed license error message * fixed typechecks * fixed license error message Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
101 lines
2.6 KiB
TypeScript
101 lines
2.6 KiB
TypeScript
/*
|
|
* 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 { SavedObjectAttribute, SavedObjectAttributes } from 'kibana/server';
|
|
import { AlertNotifyWhenType } from './alert_notify_when_type';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export type AlertTypeState = Record<string, any>;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export type AlertTypeParams = Record<string, any>;
|
|
|
|
export interface IntervalSchedule extends SavedObjectAttributes {
|
|
interval: string;
|
|
}
|
|
|
|
// for the `typeof ThingValues[number]` types below, become string types that
|
|
// only accept the values in the associated string arrays
|
|
export const AlertExecutionStatusValues = ['ok', 'active', 'error', 'pending', 'unknown'] as const;
|
|
export type AlertExecutionStatuses = typeof AlertExecutionStatusValues[number];
|
|
|
|
export enum AlertExecutionStatusErrorReasons {
|
|
Read = 'read',
|
|
Decrypt = 'decrypt',
|
|
Execute = 'execute',
|
|
Unknown = 'unknown',
|
|
License = 'license',
|
|
}
|
|
|
|
export interface AlertExecutionStatus {
|
|
status: AlertExecutionStatuses;
|
|
lastExecutionDate: Date;
|
|
error?: {
|
|
reason: AlertExecutionStatusErrorReasons;
|
|
message: string;
|
|
};
|
|
}
|
|
|
|
export type AlertActionParams = SavedObjectAttributes;
|
|
export type AlertActionParam = SavedObjectAttribute;
|
|
|
|
export interface AlertAction {
|
|
group: string;
|
|
id: string;
|
|
actionTypeId: string;
|
|
params: AlertActionParams;
|
|
}
|
|
|
|
export interface AlertAggregations {
|
|
alertExecutionStatus: { [status: string]: number };
|
|
}
|
|
|
|
export interface Alert {
|
|
id: string;
|
|
enabled: boolean;
|
|
name: string;
|
|
tags: string[];
|
|
alertTypeId: string;
|
|
consumer: string;
|
|
schedule: IntervalSchedule;
|
|
actions: AlertAction[];
|
|
params: AlertTypeParams;
|
|
scheduledTaskId?: string;
|
|
createdBy: string | null;
|
|
updatedBy: string | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
apiKey: string | null;
|
|
apiKeyOwner: string | null;
|
|
throttle: string | null;
|
|
notifyWhen: AlertNotifyWhenType | null;
|
|
muteAll: boolean;
|
|
mutedInstanceIds: string[];
|
|
executionStatus: AlertExecutionStatus;
|
|
}
|
|
|
|
export type SanitizedAlert = Omit<Alert, 'apiKey'>;
|
|
|
|
export enum HealthStatus {
|
|
OK = 'ok',
|
|
Warning = 'warn',
|
|
Error = 'error',
|
|
}
|
|
|
|
export interface AlertsHealth {
|
|
decryptionHealth: {
|
|
status: HealthStatus;
|
|
timestamp: string;
|
|
};
|
|
executionHealth: {
|
|
status: HealthStatus;
|
|
timestamp: string;
|
|
};
|
|
readHealth: {
|
|
status: HealthStatus;
|
|
timestamp: string;
|
|
};
|
|
}
|