mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
Resolves https://github.com/elastic/kibana/issues/162264 ## Summary Adds a limit on the maximum number of actions that can be queued with a circuit breaker. The limit in serverless is set to 10,000, and 1,000,000 in the other environments. - If a rule execution exceeds the limit, the circuit breaker kicks in and stops triggering actions. - Alerting rule's status updated to warning when circuit breaker is hit Did not update the `enqueueExecution` bc it's going to be removed in https://github.com/elastic/kibana/pull/165120. ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### To Verify - Create a 2 rules that have actions - Set `xpack.actions.queued.max` in kibana.yml to a low number like 2 or 3 - Use the run soon button to queue up actions and hit the circuit breaker. - The actions will not be scheduled and the rule status will be set to warning --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
240 lines
6.3 KiB
TypeScript
240 lines
6.3 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
|
|
* 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 { Duration } from 'moment';
|
|
import { Stream } from 'stream';
|
|
|
|
import { ByteSizeValue } from './src/byte_size_value';
|
|
import { ContextReference, Reference, SiblingReference } from './src/references';
|
|
import {
|
|
AnyType,
|
|
ArrayOptions,
|
|
ArrayType,
|
|
BooleanType,
|
|
BufferType,
|
|
ByteSizeOptions,
|
|
ByteSizeType,
|
|
ConditionalType,
|
|
ConditionalTypeValue,
|
|
DurationOptions,
|
|
DurationType,
|
|
IpOptions,
|
|
IpType,
|
|
LiteralType,
|
|
MapOfOptions,
|
|
MapOfType,
|
|
MaybeType,
|
|
NeverType,
|
|
NumberOptions,
|
|
NumberType,
|
|
ObjectType,
|
|
ObjectTypeOptions,
|
|
Props,
|
|
NullableProps,
|
|
RecordOfOptions,
|
|
RecordOfType,
|
|
SchemaStructureEntry,
|
|
StringOptions,
|
|
StringType,
|
|
Type,
|
|
TypeOf,
|
|
TypeOptions,
|
|
UnionType,
|
|
URIOptions,
|
|
URIType,
|
|
StreamType,
|
|
} from './src/types';
|
|
|
|
export type { AnyType, ConditionalType, TypeOf, Props, SchemaStructureEntry, NullableProps };
|
|
export { ObjectType, Type };
|
|
export { ByteSizeValue } from './src/byte_size_value';
|
|
export { SchemaTypeError, ValidationError } from './src/errors';
|
|
export { isConfigSchema } from './src/typeguards';
|
|
export { offeringBasedSchema } from './src/helpers';
|
|
|
|
function any(options?: TypeOptions<any>) {
|
|
return new AnyType(options);
|
|
}
|
|
|
|
function boolean(options?: TypeOptions<boolean>): Type<boolean> {
|
|
return new BooleanType(options);
|
|
}
|
|
|
|
function buffer(options?: TypeOptions<Buffer>): Type<Buffer> {
|
|
return new BufferType(options);
|
|
}
|
|
|
|
function stream(options?: TypeOptions<Stream>): Type<Stream> {
|
|
return new StreamType(options);
|
|
}
|
|
|
|
function string(options?: StringOptions): Type<string> {
|
|
return new StringType(options);
|
|
}
|
|
|
|
function uri(options?: URIOptions): Type<string> {
|
|
return new URIType(options);
|
|
}
|
|
|
|
function literal<T extends string | number | boolean | null>(value: T): Type<T> {
|
|
return new LiteralType(value);
|
|
}
|
|
|
|
function number(options?: NumberOptions): Type<number> {
|
|
return new NumberType(options);
|
|
}
|
|
|
|
function byteSize(options?: ByteSizeOptions): Type<ByteSizeValue> {
|
|
return new ByteSizeType(options);
|
|
}
|
|
|
|
function duration(options?: DurationOptions): Type<Duration> {
|
|
return new DurationType(options);
|
|
}
|
|
|
|
function never(): Type<never> {
|
|
return new NeverType();
|
|
}
|
|
|
|
function ip(options?: IpOptions): Type<string> {
|
|
return new IpType(options);
|
|
}
|
|
|
|
/**
|
|
* Create an optional type
|
|
*/
|
|
function maybe<V>(type: Type<V>): Type<V | undefined> {
|
|
return new MaybeType(type);
|
|
}
|
|
|
|
function nullable<V>(type: Type<V>): Type<V | null> {
|
|
return schema.oneOf([type, schema.literal(null)], { defaultValue: null });
|
|
}
|
|
|
|
function object<P extends Props>(props: P, options?: ObjectTypeOptions<P>): ObjectType<P> {
|
|
return new ObjectType(props, options);
|
|
}
|
|
|
|
function arrayOf<T>(itemType: Type<T>, options?: ArrayOptions<T>): Type<T[]> {
|
|
return new ArrayType(itemType, options);
|
|
}
|
|
|
|
function mapOf<K, V>(
|
|
keyType: Type<K>,
|
|
valueType: Type<V>,
|
|
options?: MapOfOptions<K, V>
|
|
): Type<Map<K, V>> {
|
|
return new MapOfType(keyType, valueType, options);
|
|
}
|
|
|
|
function recordOf<K extends string, V>(
|
|
keyType: Type<K>,
|
|
valueType: Type<V>,
|
|
options?: RecordOfOptions<K, V>
|
|
): Type<Record<K, V>> {
|
|
return new RecordOfType(keyType, valueType, options);
|
|
}
|
|
|
|
function oneOf<A, B, C, D, E, F, G, H, I, J, K>(
|
|
types: [
|
|
Type<A>,
|
|
Type<B>,
|
|
Type<C>,
|
|
Type<D>,
|
|
Type<E>,
|
|
Type<F>,
|
|
Type<G>,
|
|
Type<H>,
|
|
Type<I>,
|
|
Type<J>,
|
|
Type<K>
|
|
],
|
|
options?: TypeOptions<A | B | C | D | E | F | G | H | I | J | K>
|
|
): Type<A | B | C | D | E | F | G | H | I | J | K>;
|
|
function oneOf<A, B, C, D, E, F, G, H, I, J>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>, Type<F>, Type<G>, Type<H>, Type<I>, Type<J>],
|
|
options?: TypeOptions<A | B | C | D | E | F | G | H | I | J>
|
|
): Type<A | B | C | D | E | F | G | H | I | J>;
|
|
function oneOf<A, B, C, D, E, F, G, H, I>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>, Type<F>, Type<G>, Type<H>, Type<I>],
|
|
options?: TypeOptions<A | B | C | D | E | F | G | H | I>
|
|
): Type<A | B | C | D | E | F | G | H | I>;
|
|
function oneOf<A, B, C, D, E, F, G, H>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>, Type<F>, Type<G>, Type<H>],
|
|
options?: TypeOptions<A | B | C | D | E | F | G | H>
|
|
): Type<A | B | C | D | E | F | G | H>;
|
|
function oneOf<A, B, C, D, E, F, G>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>, Type<F>, Type<G>],
|
|
options?: TypeOptions<A | B | C | D | E | F | G>
|
|
): Type<A | B | C | D | E | F | G>;
|
|
function oneOf<A, B, C, D, E, F>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>, Type<F>],
|
|
options?: TypeOptions<A | B | C | D | E | F>
|
|
): Type<A | B | C | D | E | F>;
|
|
function oneOf<A, B, C, D, E>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>, Type<E>],
|
|
options?: TypeOptions<A | B | C | D | E>
|
|
): Type<A | B | C | D | E>;
|
|
function oneOf<A, B, C, D>(
|
|
types: [Type<A>, Type<B>, Type<C>, Type<D>],
|
|
options?: TypeOptions<A | B | C | D>
|
|
): Type<A | B | C | D>;
|
|
function oneOf<A, B, C>(
|
|
types: [Type<A>, Type<B>, Type<C>],
|
|
options?: TypeOptions<A | B | C>
|
|
): Type<A | B | C>;
|
|
function oneOf<A, B>(types: [Type<A>, Type<B>], options?: TypeOptions<A | B>): Type<A | B>;
|
|
function oneOf<A>(types: [Type<A>], options?: TypeOptions<A>): Type<A>;
|
|
function oneOf<RTS extends Array<Type<any>>>(types: RTS, options?: TypeOptions<any>): Type<any> {
|
|
return new UnionType(types, options);
|
|
}
|
|
|
|
function contextRef<T>(key: string): ContextReference<T> {
|
|
return new ContextReference(key);
|
|
}
|
|
|
|
function siblingRef<T>(key: string): SiblingReference<T> {
|
|
return new SiblingReference(key);
|
|
}
|
|
|
|
function conditional<A extends ConditionalTypeValue, B, C>(
|
|
leftOperand: Reference<A>,
|
|
rightOperand: Reference<A> | A | Type<unknown>,
|
|
equalType: Type<B>,
|
|
notEqualType: Type<C>,
|
|
options?: TypeOptions<B | C>
|
|
) {
|
|
return new ConditionalType(leftOperand, rightOperand, equalType, notEqualType, options);
|
|
}
|
|
|
|
export const schema = {
|
|
any,
|
|
arrayOf,
|
|
boolean,
|
|
buffer,
|
|
byteSize,
|
|
conditional,
|
|
contextRef,
|
|
duration,
|
|
ip,
|
|
literal,
|
|
mapOf,
|
|
maybe,
|
|
nullable,
|
|
never,
|
|
number,
|
|
object,
|
|
oneOf,
|
|
recordOf,
|
|
stream,
|
|
siblingRef,
|
|
string,
|
|
uri,
|
|
};
|
|
|
|
export type Schema = typeof schema;
|