mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
This reverts commit7bb2dad38f
. Original PR https://github.com/elastic/kibana/pull/204882 caused errors updating alert data stream index mappings in serverless. This seems to be a difference in the Elasticsearch client code handling requests with a body param vs requests without a body parama4315a905e (diff-07b3475acb306ea63796d4e5cc559c073a63b84c8deeb9948d9ef24fb04c6439)
This commit is contained in:
parent
7f98b6bf5d
commit
b219962bda
121 changed files with 974 additions and 873 deletions
|
@ -13,7 +13,7 @@ import type {
|
||||||
QueryDslFieldAndFormat,
|
QueryDslFieldAndFormat,
|
||||||
QueryDslQueryContainer,
|
QueryDslQueryContainer,
|
||||||
SortCombinations,
|
SortCombinations,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { Alert } from './alert_type';
|
import type { Alert } from './alert_type';
|
||||||
|
|
||||||
export type RuleRegistrySearchRequest = IEsSearchRequest & {
|
export type RuleRegistrySearchRequest = IEsSearchRequest & {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import type {
|
||||||
QueryDslFieldAndFormat,
|
QueryDslFieldAndFormat,
|
||||||
QueryDslQueryContainer,
|
QueryDslQueryContainer,
|
||||||
SortCombinations,
|
SortCombinations,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { EsQuerySnapshot, LegacyField } from '../../types';
|
import type { EsQuerySnapshot, LegacyField } from '../../types';
|
||||||
|
|
||||||
export interface SearchAlertsParams {
|
export interface SearchAlertsParams {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import type {
|
||||||
AggregationsAggregationContainer,
|
AggregationsAggregationContainer,
|
||||||
QueryDslQueryContainer,
|
QueryDslQueryContainer,
|
||||||
SortCombinations,
|
SortCombinations,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { BASE_RAC_ALERTS_API_PATH } from '../constants';
|
import { BASE_RAC_ALERTS_API_PATH } from '../constants';
|
||||||
|
|
||||||
export interface UseGetAlertsGroupAggregationsQueryProps {
|
export interface UseGetAlertsGroupAggregationsQueryProps {
|
||||||
|
|
|
@ -11,10 +11,10 @@ import type {
|
||||||
Script,
|
Script,
|
||||||
MappingRuntimeField,
|
MappingRuntimeField,
|
||||||
MappingRuntimeFields,
|
MappingRuntimeFields,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { RuntimeFieldSpec, RuntimePrimitiveTypes } from '@kbn/data-views-plugin/common';
|
import type { RuntimeFieldSpec, RuntimePrimitiveTypes } from '@kbn/data-views-plugin/common';
|
||||||
import type { BoolQuery } from '@kbn/es-query';
|
import type { BoolQuery } from '@kbn/es-query';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
type RunTimeMappings =
|
type RunTimeMappings =
|
||||||
| Record<string, Omit<RuntimeFieldSpec, 'type'> & { type: RuntimePrimitiveTypes }>
|
| Record<string, Omit<RuntimeFieldSpec, 'type'> & { type: RuntimePrimitiveTypes }>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/**
|
/**
|
||||||
* Get all actions with in-memory connectors
|
* Get all actions with in-memory connectors
|
||||||
*/
|
*/
|
||||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { AuditLogger } from '@kbn/security-plugin-types-server';
|
import { AuditLogger } from '@kbn/security-plugin-types-server';
|
||||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||||
import { omit } from 'lodash';
|
import { omit } from 'lodash';
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||||
import { SavedObjectsClient } from '@kbn/core/server';
|
import { SavedObjectsClient } from '@kbn/core/server';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { KueryNode } from '@kbn/es-query';
|
import { KueryNode } from '@kbn/es-query';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import Boom from '@hapi/boom';
|
import Boom from '@hapi/boom';
|
||||||
import { flatMap, get, isEmpty } from 'lodash';
|
import { flatMap, get, isEmpty } from 'lodash';
|
||||||
import { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/server';
|
import { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/server';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import type {
|
import type {
|
||||||
AggregationsKeyedPercentiles,
|
AggregationsKeyedPercentiles,
|
||||||
AggregationsPercentilesAggregateBase,
|
AggregationsPercentilesAggregateBase,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
|
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
|
||||||
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/server';
|
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/server';
|
||||||
import { CoreSetup } from '@kbn/core/server';
|
import { CoreSetup } from '@kbn/core/server';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||||
import { AggregationsTermsAggregateBase } from '@elastic/elasticsearch/lib/api/types';
|
import { AggregationsTermsAggregateBase } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import {
|
import {
|
||||||
AvgActionRunOutcomeByConnectorTypeBucket,
|
AvgActionRunOutcomeByConnectorTypeBucket,
|
||||||
parseActionRunOutcomeByConnectorTypesBucket,
|
parseActionRunOutcomeByConnectorTypesBucket,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/types';
|
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { replaceFirstAndLastDotSymbols } from '../actions_telemetry';
|
import { replaceFirstAndLastDotSymbols } from '../actions_telemetry';
|
||||||
|
|
||||||
export interface AvgActionRunOutcomeByConnectorTypeBucket {
|
export interface AvgActionRunOutcomeByConnectorTypeBucket {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
|
import type { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { set } from '@kbn/safer-lodash-set';
|
import { set } from '@kbn/safer-lodash-set';
|
||||||
import type { FieldMap, MultiField } from '@kbn/alerts-as-data-utils';
|
import type { FieldMap, MultiField } from '@kbn/alerts-as-data-utils';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import type {
|
import type {
|
||||||
AggregationsAggregationContainer,
|
AggregationsAggregationContainer,
|
||||||
AggregationsCompositeAggregation,
|
AggregationsCompositeAggregation,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { AggregateOptions } from '../server/application/rule/methods/aggregate/types';
|
import type { AggregateOptions } from '../server/application/rule/methods/aggregate/types';
|
||||||
|
|
||||||
export type RuleTagsAggregationOptions = Pick<AggregateOptions, 'filter' | 'search'> & {
|
export type RuleTagsAggregationOptions = Pick<AggregateOptions, 'filter' | 'search'> & {
|
||||||
|
|
|
@ -442,16 +442,18 @@ describe('Alerts Client', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(clusterClient.search).toHaveBeenCalledWith({
|
expect(clusterClient.search).toHaveBeenCalledWith({
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
filter: [
|
bool: {
|
||||||
{ term: { 'kibana.alert.rule.uuid': '1' } },
|
filter: [
|
||||||
{ terms: { 'kibana.alert.uuid': ['abc', 'def', 'xyz'] } },
|
{ term: { 'kibana.alert.rule.uuid': '1' } },
|
||||||
],
|
{ terms: { 'kibana.alert.uuid': ['abc', 'def', 'xyz'] } },
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
seq_no_primary_term: true,
|
||||||
|
size: 3,
|
||||||
},
|
},
|
||||||
seq_no_primary_term: true,
|
|
||||||
size: 3,
|
|
||||||
index: useDataStreamForAlerts
|
index: useDataStreamForAlerts
|
||||||
? '.alerts-test.alerts-default'
|
? '.alerts-test.alerts-default'
|
||||||
: '.internal.alerts-test.alerts-default-*',
|
: '.internal.alerts-test.alerts-default-*',
|
||||||
|
@ -514,16 +516,18 @@ describe('Alerts Client', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(clusterClient.search).toHaveBeenCalledWith({
|
expect(clusterClient.search).toHaveBeenCalledWith({
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
filter: [
|
bool: {
|
||||||
{ term: { 'kibana.alert.rule.uuid': '1' } },
|
filter: [
|
||||||
{ terms: { 'kibana.alert.uuid': ['abc'] } },
|
{ term: { 'kibana.alert.rule.uuid': '1' } },
|
||||||
],
|
{ terms: { 'kibana.alert.uuid': ['abc'] } },
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
size: 1,
|
||||||
|
seq_no_primary_term: true,
|
||||||
},
|
},
|
||||||
size: 1,
|
|
||||||
seq_no_primary_term: true,
|
|
||||||
index: useDataStreamForAlerts
|
index: useDataStreamForAlerts
|
||||||
? '.alerts-test.alerts-default'
|
? '.alerts-test.alerts-default'
|
||||||
: '.internal.alerts-test.alerts-default-*',
|
: '.internal.alerts-test.alerts-default-*',
|
||||||
|
@ -566,7 +570,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
||||||
},
|
},
|
||||||
|
@ -613,7 +617,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: true,
|
refresh: true,
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
||||||
},
|
},
|
||||||
|
@ -706,7 +710,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'abc',
|
_id: 'abc',
|
||||||
|
@ -779,7 +783,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'abc',
|
_id: 'abc',
|
||||||
|
@ -914,7 +918,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: {
|
create: {
|
||||||
_id: 'abc',
|
_id: 'abc',
|
||||||
|
@ -987,7 +991,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'def',
|
_id: 'def',
|
||||||
|
@ -1086,7 +1090,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'def',
|
_id: 'def',
|
||||||
|
@ -1243,7 +1247,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'def',
|
_id: 'def',
|
||||||
|
@ -1361,7 +1365,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'def',
|
_id: 'def',
|
||||||
|
@ -1565,7 +1569,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'def',
|
_id: 'def',
|
||||||
|
@ -2536,7 +2540,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
||||||
},
|
},
|
||||||
|
@ -2810,7 +2814,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: {
|
create: {
|
||||||
_id: expect.any(String),
|
_id: expect.any(String),
|
||||||
|
@ -2911,7 +2915,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: {
|
create: {
|
||||||
_id: 'abc',
|
_id: 'abc',
|
||||||
|
@ -3008,7 +3012,7 @@ describe('Alerts Client', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
index: {
|
index: {
|
||||||
_id: 'abc',
|
_id: 'abc',
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
ALERT_MAINTENANCE_WINDOW_IDS,
|
ALERT_MAINTENANCE_WINDOW_IDS,
|
||||||
} from '@kbn/rule-data-utils';
|
} from '@kbn/rule-data-utils';
|
||||||
import { chunk, flatMap, get, isEmpty, keys } from 'lodash';
|
import { chunk, flatMap, get, isEmpty, keys } from 'lodash';
|
||||||
import { SearchRequest } from '@elastic/elasticsearch/lib/api/types';
|
import { SearchRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { Alert } from '@kbn/alerts-as-data-utils';
|
import type { Alert } from '@kbn/alerts-as-data-utils';
|
||||||
import { DEFAULT_NAMESPACE_STRING } from '@kbn/core-saved-objects-utils-server';
|
import { DEFAULT_NAMESPACE_STRING } from '@kbn/core-saved-objects-utils-server';
|
||||||
import { DeepPartial } from '@kbn/utility-types';
|
import { DeepPartial } from '@kbn/utility-types';
|
||||||
|
@ -231,7 +231,7 @@ export class AlertsClient<
|
||||||
}
|
}
|
||||||
|
|
||||||
public async search<Aggregation = unknown>(
|
public async search<Aggregation = unknown>(
|
||||||
queryBody: SearchRequest
|
queryBody: SearchRequest['body']
|
||||||
): Promise<SearchResult<AlertData, Aggregation>> {
|
): Promise<SearchResult<AlertData, Aggregation>> {
|
||||||
const esClient = await this.options.elasticsearchClientPromise;
|
const esClient = await this.options.elasticsearchClientPromise;
|
||||||
const index = this.isUsingDataStreams()
|
const index = this.isUsingDataStreams()
|
||||||
|
@ -242,7 +242,7 @@ export class AlertsClient<
|
||||||
aggregations,
|
aggregations,
|
||||||
} = await esClient.search<Alert & AlertData, Aggregation>({
|
} = await esClient.search<Alert & AlertData, Aggregation>({
|
||||||
index,
|
index,
|
||||||
...queryBody,
|
body: queryBody,
|
||||||
ignore_unavailable: true,
|
ignore_unavailable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ export class AlertsClient<
|
||||||
refresh: this.isServerless ? true : 'wait_for',
|
refresh: this.isServerless ? true : 'wait_for',
|
||||||
index: this.indexTemplateAndPattern.alias,
|
index: this.indexTemplateAndPattern.alias,
|
||||||
require_alias: !this.isUsingDataStreams(),
|
require_alias: !this.isUsingDataStreams(),
|
||||||
operations: bulkBody,
|
body: bulkBody,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If there were individual indexing errors, they will be returned in the success response
|
// If there were individual indexing errors, they will be returned in the success response
|
||||||
|
|
|
@ -129,66 +129,67 @@ export const getExpectedQueryByExecutionUuid = ({
|
||||||
excludedAlertInstanceIds?: string[];
|
excludedAlertInstanceIds?: string[];
|
||||||
alertsFilter?: AlertsFilter;
|
alertsFilter?: AlertsFilter;
|
||||||
}) => ({
|
}) => ({
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
filter: [
|
bool: {
|
||||||
{ term: { 'kibana.alert.rule.execution.uuid': uuid } },
|
filter: [
|
||||||
{ term: { 'kibana.alert.rule.uuid': ruleId } },
|
{ term: { 'kibana.alert.rule.execution.uuid': uuid } },
|
||||||
{
|
{ term: { 'kibana.alert.rule.uuid': ruleId } },
|
||||||
bool: { must_not: { exists: { field: 'kibana.alert.maintenance_window_ids' } } },
|
{
|
||||||
},
|
bool: { must_not: { exists: { field: 'kibana.alert.maintenance_window_ids' } } },
|
||||||
...(isLifecycleAlert ? [{ term: { 'event.action': alertTypes[alertType] } }] : []),
|
},
|
||||||
...(!!excludedAlertInstanceIds?.length
|
...(isLifecycleAlert ? [{ term: { 'event.action': alertTypes[alertType] } }] : []),
|
||||||
? [
|
...(!!excludedAlertInstanceIds?.length
|
||||||
{
|
? [
|
||||||
bool: {
|
{
|
||||||
must_not: {
|
bool: {
|
||||||
terms: {
|
must_not: {
|
||||||
'kibana.alert.instance.id': excludedAlertInstanceIds,
|
terms: {
|
||||||
},
|
'kibana.alert.instance.id': excludedAlertInstanceIds,
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
...(alertsFilter
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
bool: {
|
|
||||||
minimum_should_match: 1,
|
|
||||||
should: [
|
|
||||||
{
|
|
||||||
match: {
|
|
||||||
[alertsFilter.query!.kql.split(':')[0]]:
|
|
||||||
alertsFilter.query!.kql.split(':')[1],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
script: {
|
|
||||||
script: {
|
|
||||||
params: {
|
|
||||||
datetimeField: '@timestamp',
|
|
||||||
days: alertsFilter.timeframe?.days,
|
|
||||||
timezone: alertsFilter.timeframe!.timezone,
|
|
||||||
},
|
|
||||||
source:
|
|
||||||
'params.days.contains(doc[params.datetimeField].value.withZoneSameInstant(ZoneId.of(params.timezone)).dayOfWeek.getValue())',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
]
|
||||||
{
|
: []),
|
||||||
script: {
|
...(alertsFilter
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
bool: {
|
||||||
|
minimum_should_match: 1,
|
||||||
|
should: [
|
||||||
|
{
|
||||||
|
match: {
|
||||||
|
[alertsFilter.query!.kql.split(':')[0]]:
|
||||||
|
alertsFilter.query!.kql.split(':')[1],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
script: {
|
script: {
|
||||||
params: {
|
script: {
|
||||||
datetimeField: '@timestamp',
|
params: {
|
||||||
end: alertsFilter.timeframe!.hours.end,
|
datetimeField: '@timestamp',
|
||||||
start: alertsFilter.timeframe!.hours.start,
|
days: alertsFilter.timeframe?.days,
|
||||||
timezone: alertsFilter.timeframe!.timezone,
|
timezone: alertsFilter.timeframe!.timezone,
|
||||||
|
},
|
||||||
|
source:
|
||||||
|
'params.days.contains(doc[params.datetimeField].value.withZoneSameInstant(ZoneId.of(params.timezone)).dayOfWeek.getValue())',
|
||||||
},
|
},
|
||||||
source: `
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
script: {
|
||||||
|
script: {
|
||||||
|
params: {
|
||||||
|
datetimeField: '@timestamp',
|
||||||
|
end: alertsFilter.timeframe!.hours.end,
|
||||||
|
start: alertsFilter.timeframe!.hours.start,
|
||||||
|
timezone: alertsFilter.timeframe!.timezone,
|
||||||
|
},
|
||||||
|
source: `
|
||||||
def alertsDateTime = doc[params.datetimeField].value.withZoneSameInstant(ZoneId.of(params.timezone));
|
def alertsDateTime = doc[params.datetimeField].value.withZoneSameInstant(ZoneId.of(params.timezone));
|
||||||
def alertsTime = LocalTime.of(alertsDateTime.getHour(), alertsDateTime.getMinute());
|
def alertsTime = LocalTime.of(alertsDateTime.getHour(), alertsDateTime.getMinute());
|
||||||
def start = LocalTime.parse(params.start);
|
def start = LocalTime.parse(params.start);
|
||||||
|
@ -210,16 +211,17 @@ export const getExpectedQueryByExecutionUuid = ({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
]
|
||||||
]
|
: []),
|
||||||
: []),
|
],
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
|
size: 100,
|
||||||
|
track_total_hits: true,
|
||||||
},
|
},
|
||||||
size: 100,
|
|
||||||
track_total_hits: true,
|
|
||||||
ignore_unavailable: true,
|
ignore_unavailable: true,
|
||||||
index: indexName,
|
index: indexName,
|
||||||
});
|
});
|
||||||
|
@ -374,13 +376,15 @@ export const getExpectedQueryByTimeRange = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
filter,
|
bool: {
|
||||||
|
filter,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
size: 100,
|
||||||
|
track_total_hits: true,
|
||||||
},
|
},
|
||||||
size: 100,
|
|
||||||
track_total_hits: true,
|
|
||||||
ignore_unavailable: true,
|
ignore_unavailable: true,
|
||||||
index: indexName,
|
index: indexName,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
SearchRequest,
|
SearchRequest,
|
||||||
SearchTotalHits,
|
SearchTotalHits,
|
||||||
AggregationsAggregationContainer,
|
AggregationsAggregationContainer,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { BoolQuery } from '@kbn/es-query';
|
import { BoolQuery } from '@kbn/es-query';
|
||||||
import {
|
import {
|
||||||
ALERT_END,
|
ALERT_END,
|
||||||
|
@ -53,7 +53,7 @@ const getLifecycleAlertsQueryByExecutionUuid = ({
|
||||||
ruleId,
|
ruleId,
|
||||||
excludedAlertInstanceIds,
|
excludedAlertInstanceIds,
|
||||||
alertsFilter,
|
alertsFilter,
|
||||||
}: GetLifecycleAlertsQueryByExecutionUuidParams): SearchRequest[] => {
|
}: GetLifecycleAlertsQueryByExecutionUuidParams): Array<SearchRequest['body']> => {
|
||||||
// lifecycle alerts assign a different action to an alert depending
|
// lifecycle alerts assign a different action to an alert depending
|
||||||
// on whether it is new/ongoing/recovered. query for each action in order
|
// on whether it is new/ongoing/recovered. query for each action in order
|
||||||
// to get the count of each action type as well as up to the maximum number
|
// to get the count of each action type as well as up to the maximum number
|
||||||
|
@ -89,7 +89,7 @@ const getLifecycleAlertsQueryByTimeRange = ({
|
||||||
ruleId,
|
ruleId,
|
||||||
excludedAlertInstanceIds,
|
excludedAlertInstanceIds,
|
||||||
alertsFilter,
|
alertsFilter,
|
||||||
}: GetLifecycleAlertsQueryByTimeRangeParams): SearchRequest[] => {
|
}: GetLifecycleAlertsQueryByTimeRangeParams): Array<SearchRequest['body']> => {
|
||||||
return [
|
return [
|
||||||
getQueryByTimeRange({
|
getQueryByTimeRange({
|
||||||
start,
|
start,
|
||||||
|
@ -124,7 +124,7 @@ const getQueryByExecutionUuid = ({
|
||||||
excludedAlertInstanceIds,
|
excludedAlertInstanceIds,
|
||||||
action,
|
action,
|
||||||
alertsFilter,
|
alertsFilter,
|
||||||
}: GetQueryByExecutionUuidParams): SearchRequest => {
|
}: GetQueryByExecutionUuidParams): SearchRequest['body'] => {
|
||||||
const filter: QueryDslQueryContainer[] = [
|
const filter: QueryDslQueryContainer[] = [
|
||||||
{
|
{
|
||||||
term: {
|
term: {
|
||||||
|
@ -187,7 +187,7 @@ const getQueryByTimeRange = ({
|
||||||
excludedAlertInstanceIds,
|
excludedAlertInstanceIds,
|
||||||
type,
|
type,
|
||||||
alertsFilter,
|
alertsFilter,
|
||||||
}: GetQueryByTimeRangeParams<AlertTypes>): SearchRequest => {
|
}: GetQueryByTimeRangeParams<AlertTypes>): SearchRequest['body'] => {
|
||||||
// base query filters the alert documents for a rule by the given time range
|
// base query filters the alert documents for a rule by the given time range
|
||||||
let filter: QueryDslQueryContainer[] = [
|
let filter: QueryDslQueryContainer[] = [
|
||||||
{
|
{
|
||||||
|
@ -282,7 +282,7 @@ export const getQueryByScopedQueries = ({
|
||||||
ruleId,
|
ruleId,
|
||||||
action,
|
action,
|
||||||
maintenanceWindows,
|
maintenanceWindows,
|
||||||
}: GetQueryByScopedQueriesParams): SearchRequest => {
|
}: GetQueryByScopedQueriesParams): SearchRequest['body'] => {
|
||||||
const filters: QueryDslQueryContainer[] = [
|
const filters: QueryDslQueryContainer[] = [
|
||||||
{
|
{
|
||||||
term: {
|
term: {
|
||||||
|
@ -460,7 +460,7 @@ const getLifecycleAlertsQueries = ({
|
||||||
ruleId,
|
ruleId,
|
||||||
excludedAlertInstanceIds,
|
excludedAlertInstanceIds,
|
||||||
alertsFilter,
|
alertsFilter,
|
||||||
}: GetAlertsQueryParams): SearchRequest[] => {
|
}: GetAlertsQueryParams): Array<SearchRequest['body']> => {
|
||||||
let queryBodies;
|
let queryBodies;
|
||||||
if (!!executionUuid) {
|
if (!!executionUuid) {
|
||||||
queryBodies = getLifecycleAlertsQueryByExecutionUuid({
|
queryBodies = getLifecycleAlertsQueryByExecutionUuid({
|
||||||
|
@ -489,7 +489,7 @@ const getContinualAlertsQuery = ({
|
||||||
ruleId,
|
ruleId,
|
||||||
excludedAlertInstanceIds,
|
excludedAlertInstanceIds,
|
||||||
alertsFilter,
|
alertsFilter,
|
||||||
}: GetAlertsQueryParams): SearchRequest => {
|
}: GetAlertsQueryParams): SearchRequest['body'] => {
|
||||||
let queryBody;
|
let queryBody;
|
||||||
if (!!executionUuid) {
|
if (!!executionUuid) {
|
||||||
queryBody = getQueryByExecutionUuid({
|
queryBody = getQueryByExecutionUuid({
|
||||||
|
@ -516,7 +516,7 @@ const getMaintenanceWindowAlertsQuery = ({
|
||||||
ruleId,
|
ruleId,
|
||||||
action,
|
action,
|
||||||
maintenanceWindows,
|
maintenanceWindows,
|
||||||
}: GetMaintenanceWindowAlertsQueryParams): SearchRequest => {
|
}: GetMaintenanceWindowAlertsQueryParams): SearchRequest['body'] => {
|
||||||
return getQueryByScopedQueries({
|
return getQueryByScopedQueries({
|
||||||
executionUuid,
|
executionUuid,
|
||||||
ruleId,
|
ruleId,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
export const injectAnalyzeWildcard = (query: QueryDslQueryContainer): void => {
|
export const injectAnalyzeWildcard = (query: QueryDslQueryContainer): void => {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import { TransportResult } from '@elastic/elasticsearch';
|
import { TransportResult } from '@elastic/elasticsearch';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { sanitizeBulkErrorResponse } from './sanitize_bulk_response';
|
import { sanitizeBulkErrorResponse } from './sanitize_bulk_response';
|
||||||
|
|
||||||
// Using https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-bulk.html
|
// Using https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-bulk.html
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { cloneDeep } from 'lodash';
|
||||||
import { TransportResult } from '@elastic/elasticsearch';
|
import { TransportResult } from '@elastic/elasticsearch';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { set } from '@kbn/safer-lodash-set';
|
import { set } from '@kbn/safer-lodash-set';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
export const sanitizeBulkErrorResponse = (
|
export const sanitizeBulkErrorResponse = (
|
||||||
response: TransportResult<estypes.BulkResponse, unknown> | estypes.BulkResponse
|
response: TransportResult<estypes.BulkResponse, unknown> | estypes.BulkResponse
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-m
|
||||||
import {
|
import {
|
||||||
IndicesGetDataStreamResponse,
|
IndicesGetDataStreamResponse,
|
||||||
IndicesDataStreamIndex,
|
IndicesDataStreamIndex,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { errors as EsErrors } from '@elastic/elasticsearch';
|
import { errors as EsErrors } from '@elastic/elasticsearch';
|
||||||
import { ReplaySubject, Subject, of } from 'rxjs';
|
import { ReplaySubject, Subject, of } from 'rxjs';
|
||||||
import { AlertsService } from './alerts_service';
|
import { AlertsService } from './alerts_service';
|
||||||
|
@ -150,52 +150,54 @@ const getIndexTemplatePutBody = (opts?: GetIndexTemplatePutBodyOpts) => {
|
||||||
];
|
];
|
||||||
return {
|
return {
|
||||||
name: `.alerts-${context ? context : 'test'}.alerts-${namespace}-index-template`,
|
name: `.alerts-${context ? context : 'test'}.alerts-${namespace}-index-template`,
|
||||||
index_patterns: indexPatterns,
|
body: {
|
||||||
composed_of: [
|
index_patterns: indexPatterns,
|
||||||
...(useEcs ? ['.alerts-ecs-mappings'] : []),
|
composed_of: [
|
||||||
`.alerts-${context ? `${context}.alerts` : 'test.alerts'}-mappings`,
|
...(useEcs ? ['.alerts-ecs-mappings'] : []),
|
||||||
...(useLegacyAlerts ? ['.alerts-legacy-alert-mappings'] : []),
|
`.alerts-${context ? `${context}.alerts` : 'test.alerts'}-mappings`,
|
||||||
'.alerts-framework-mappings',
|
...(useLegacyAlerts ? ['.alerts-legacy-alert-mappings'] : []),
|
||||||
],
|
'.alerts-framework-mappings',
|
||||||
...(useDataStream ? { data_stream: { hidden: true } } : {}),
|
],
|
||||||
priority: namespace.length,
|
...(useDataStream ? { data_stream: { hidden: true } } : {}),
|
||||||
template: {
|
priority: namespace.length,
|
||||||
settings: {
|
template: {
|
||||||
auto_expand_replicas: '0-1',
|
settings: {
|
||||||
hidden: true,
|
auto_expand_replicas: '0-1',
|
||||||
...(useDataStream
|
hidden: true,
|
||||||
? {}
|
...(useDataStream
|
||||||
: {
|
? {}
|
||||||
'index.lifecycle': {
|
: {
|
||||||
name: '.alerts-ilm-policy',
|
'index.lifecycle': {
|
||||||
rollover_alias: `.alerts-${context ? context : 'test'}.alerts-${namespace}`,
|
name: '.alerts-ilm-policy',
|
||||||
},
|
rollover_alias: `.alerts-${context ? context : 'test'}.alerts-${namespace}`,
|
||||||
}),
|
},
|
||||||
'index.mapping.ignore_malformed': true,
|
}),
|
||||||
'index.mapping.total_fields.limit': 2500,
|
'index.mapping.ignore_malformed': true,
|
||||||
},
|
'index.mapping.total_fields.limit': 2500,
|
||||||
mappings: {
|
|
||||||
dynamic: false,
|
|
||||||
_meta: {
|
|
||||||
kibana: { version: '8.8.0' },
|
|
||||||
managed: true,
|
|
||||||
namespace,
|
|
||||||
},
|
},
|
||||||
},
|
mappings: {
|
||||||
...(secondaryAlias
|
dynamic: false,
|
||||||
? {
|
_meta: {
|
||||||
aliases: {
|
kibana: { version: '8.8.0' },
|
||||||
[`${secondaryAlias}-default`]: {
|
managed: true,
|
||||||
is_write_index: false,
|
namespace,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...(secondaryAlias
|
||||||
|
? {
|
||||||
|
aliases: {
|
||||||
|
[`${secondaryAlias}-default`]: {
|
||||||
|
is_write_index: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
: {}),
|
||||||
: {}),
|
},
|
||||||
},
|
_meta: {
|
||||||
_meta: {
|
kibana: { version: '8.8.0' },
|
||||||
kibana: { version: '8.8.0' },
|
managed: true,
|
||||||
managed: true,
|
namespace,
|
||||||
namespace,
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -471,12 +473,14 @@ describe('Alerts Service', () => {
|
||||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
||||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
||||||
name: existingIndexTemplate.name,
|
name: existingIndexTemplate.name,
|
||||||
...existingIndexTemplate.index_template,
|
body: {
|
||||||
template: {
|
...existingIndexTemplate.index_template,
|
||||||
...existingIndexTemplate.index_template.template,
|
template: {
|
||||||
settings: {
|
...existingIndexTemplate.index_template.template,
|
||||||
...existingIndexTemplate.index_template.template?.settings,
|
settings: {
|
||||||
'index.mapping.total_fields.limit': 2500,
|
...existingIndexTemplate.index_template.template?.settings,
|
||||||
|
'index.mapping.total_fields.limit': 2500,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -554,9 +558,11 @@ describe('Alerts Service', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -618,9 +624,11 @@ describe('Alerts Service', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -678,9 +686,11 @@ describe('Alerts Service', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -721,9 +731,11 @@ describe('Alerts Service', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenNthCalledWith(1, {
|
expect(clusterClient.indices.create).toHaveBeenNthCalledWith(1, {
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -786,9 +798,11 @@ describe('Alerts Service', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenNthCalledWith(2, {
|
expect(clusterClient.indices.create).toHaveBeenNthCalledWith(2, {
|
||||||
index: '.internal.alerts-test.alerts-another-namespace-000001',
|
index: '.internal.alerts-test.alerts-another-namespace-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-another-namespace': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-another-namespace': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -841,9 +855,11 @@ describe('Alerts Service', () => {
|
||||||
expect(clusterClient.indices.putMapping).toHaveBeenCalledTimes(2);
|
expect(clusterClient.indices.putMapping).toHaveBeenCalledTimes(2);
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -875,43 +891,45 @@ describe('Alerts Service', () => {
|
||||||
|
|
||||||
const template = {
|
const template = {
|
||||||
name: `.alerts-empty.alerts-default-index-template`,
|
name: `.alerts-empty.alerts-default-index-template`,
|
||||||
index_patterns: useDataStreamForAlerts
|
body: {
|
||||||
? [`.alerts-empty.alerts-default`]
|
index_patterns: useDataStreamForAlerts
|
||||||
: [
|
? [`.alerts-empty.alerts-default`]
|
||||||
`.internal.alerts-empty.alerts-default-*`,
|
: [
|
||||||
`.reindexed-v8-internal.alerts-empty.alerts-default-*`,
|
`.internal.alerts-empty.alerts-default-*`,
|
||||||
],
|
`.reindexed-v8-internal.alerts-empty.alerts-default-*`,
|
||||||
composed_of: ['.alerts-framework-mappings'],
|
],
|
||||||
...(useDataStreamForAlerts ? { data_stream: { hidden: true } } : {}),
|
composed_of: ['.alerts-framework-mappings'],
|
||||||
priority: 7,
|
...(useDataStreamForAlerts ? { data_stream: { hidden: true } } : {}),
|
||||||
template: {
|
priority: 7,
|
||||||
settings: {
|
template: {
|
||||||
auto_expand_replicas: '0-1',
|
settings: {
|
||||||
hidden: true,
|
auto_expand_replicas: '0-1',
|
||||||
...(useDataStreamForAlerts
|
hidden: true,
|
||||||
? {}
|
...(useDataStreamForAlerts
|
||||||
: {
|
? {}
|
||||||
'index.lifecycle': {
|
: {
|
||||||
name: '.alerts-ilm-policy',
|
'index.lifecycle': {
|
||||||
rollover_alias: `.alerts-empty.alerts-default`,
|
name: '.alerts-ilm-policy',
|
||||||
},
|
rollover_alias: `.alerts-empty.alerts-default`,
|
||||||
}),
|
},
|
||||||
'index.mapping.ignore_malformed': true,
|
}),
|
||||||
'index.mapping.total_fields.limit': 2500,
|
'index.mapping.ignore_malformed': true,
|
||||||
},
|
'index.mapping.total_fields.limit': 2500,
|
||||||
mappings: {
|
},
|
||||||
_meta: {
|
mappings: {
|
||||||
kibana: { version: '8.8.0' },
|
_meta: {
|
||||||
managed: true,
|
kibana: { version: '8.8.0' },
|
||||||
namespace: 'default',
|
managed: true,
|
||||||
|
namespace: 'default',
|
||||||
|
},
|
||||||
|
dynamic: false,
|
||||||
},
|
},
|
||||||
dynamic: false,
|
|
||||||
},
|
},
|
||||||
},
|
_meta: {
|
||||||
_meta: {
|
kibana: { version: '8.8.0' },
|
||||||
kibana: { version: '8.8.0' },
|
managed: true,
|
||||||
managed: true,
|
namespace: 'default',
|
||||||
namespace: 'default',
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -926,9 +944,11 @@ describe('Alerts Service', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-empty.alerts-default-000001',
|
index: '.internal.alerts-empty.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-empty.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-empty.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IlmPolicy } from '@elastic/elasticsearch/lib/api/types';
|
import { IlmPolicy } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default alert index ILM policy
|
* Default alert index ILM policy
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
|
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
|
||||||
import { errors as EsErrors } from '@elastic/elasticsearch';
|
import { errors as EsErrors } from '@elastic/elasticsearch';
|
||||||
import { IndicesGetDataStreamResponse } from '@elastic/elasticsearch/lib/api/types';
|
import { IndicesGetDataStreamResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { createConcreteWriteIndex, setConcreteWriteIndex } from './create_concrete_write_index';
|
import { createConcreteWriteIndex, setConcreteWriteIndex } from './create_concrete_write_index';
|
||||||
import { getDataStreamAdapter } from './data_stream_adapter';
|
import { getDataStreamAdapter } from './data_stream_adapter';
|
||||||
|
|
||||||
|
@ -95,9 +95,11 @@ describe('createConcreteWriteIndex', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -307,9 +309,11 @@ describe('createConcreteWriteIndex', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -355,9 +359,11 @@ describe('createConcreteWriteIndex', () => {
|
||||||
if (!useDataStream) {
|
if (!useDataStream) {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -393,9 +399,11 @@ describe('createConcreteWriteIndex', () => {
|
||||||
if (!useDataStream) {
|
if (!useDataStream) {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -623,9 +631,11 @@ describe('createConcreteWriteIndex', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -660,9 +670,11 @@ describe('createConcreteWriteIndex', () => {
|
||||||
} else {
|
} else {
|
||||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||||
index: '.internal.alerts-test.alerts-default-000001',
|
index: '.internal.alerts-test.alerts-default-000001',
|
||||||
aliases: {
|
body: {
|
||||||
'.alerts-test.alerts-default': {
|
aliases: {
|
||||||
is_write_index: true,
|
'.alerts-test.alerts-default': {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -744,21 +756,23 @@ describe('setConcreteWriteIndex', () => {
|
||||||
'Attempting to set index: .internal.alerts-test.alerts-default-000004 as the write index for alias: .alerts-test.alerts-default.'
|
'Attempting to set index: .internal.alerts-test.alerts-default-000004 as the write index for alias: .alerts-test.alerts-default.'
|
||||||
);
|
);
|
||||||
expect(clusterClient.indices.updateAliases).toHaveBeenCalledWith({
|
expect(clusterClient.indices.updateAliases).toHaveBeenCalledWith({
|
||||||
actions: [
|
body: {
|
||||||
{
|
actions: [
|
||||||
remove: {
|
{
|
||||||
alias: '.alerts-test.alerts-default',
|
remove: {
|
||||||
index: '.internal.alerts-test.alerts-default-000004',
|
alias: '.alerts-test.alerts-default',
|
||||||
|
index: '.internal.alerts-test.alerts-default-000004',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
add: {
|
||||||
add: {
|
alias: '.alerts-test.alerts-default',
|
||||||
alias: '.alerts-test.alerts-default',
|
index: '.internal.alerts-test.alerts-default-000004',
|
||||||
index: '.internal.alerts-test.alerts-default-000004',
|
is_write_index: true,
|
||||||
is_write_index: true,
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
});
|
});
|
||||||
expect(logger.info).toHaveBeenCalledWith(
|
expect(logger.info).toHaveBeenCalledWith(
|
||||||
'Successfully set index: .internal.alerts-test.alerts-default-000004 as the write index for alias: .alerts-test.alerts-default.'
|
'Successfully set index: .internal.alerts-test.alerts-default-000004 as the write index for alias: .alerts-test.alerts-default.'
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IndicesSimulateIndexTemplateResponse } from '@elastic/elasticsearch/lib/api/types';
|
import { IndicesSimulateIndexTemplateResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||||
import { get, sortBy } from 'lodash';
|
import { get, sortBy } from 'lodash';
|
||||||
import { IIndexPatternString } from '../resource_installer_utils';
|
import { IIndexPatternString } from '../resource_installer_utils';
|
||||||
|
@ -45,7 +45,7 @@ const updateTotalFieldLimitSetting = async ({
|
||||||
() =>
|
() =>
|
||||||
esClient.indices.putSettings({
|
esClient.indices.putSettings({
|
||||||
index,
|
index,
|
||||||
settings: { 'index.mapping.total_fields.limit': totalFieldsLimit },
|
body: { 'index.mapping.total_fields.limit': totalFieldsLimit },
|
||||||
}),
|
}),
|
||||||
{ logger }
|
{ logger }
|
||||||
);
|
);
|
||||||
|
@ -90,7 +90,7 @@ const updateUnderlyingMapping = async ({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await retryTransientEsErrors(
|
await retryTransientEsErrors(
|
||||||
() => esClient.indices.putMapping({ index, ...simulatedMapping }),
|
() => esClient.indices.putMapping({ index, body: simulatedMapping }),
|
||||||
{ logger }
|
{ logger }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -183,16 +183,18 @@ export async function setConcreteWriteIndex(opts: SetConcreteWriteIndexOpts) {
|
||||||
await retryTransientEsErrors(
|
await retryTransientEsErrors(
|
||||||
() =>
|
() =>
|
||||||
esClient.indices.updateAliases({
|
esClient.indices.updateAliases({
|
||||||
actions: [
|
body: {
|
||||||
{ remove: { index: concreteIndex.index, alias: concreteIndex.alias } },
|
actions: [
|
||||||
{
|
{ remove: { index: concreteIndex.index, alias: concreteIndex.alias } },
|
||||||
add: {
|
{
|
||||||
index: concreteIndex.index,
|
add: {
|
||||||
alias: concreteIndex.alias,
|
index: concreteIndex.index,
|
||||||
is_write_index: true,
|
alias: concreteIndex.alias,
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
}),
|
}),
|
||||||
{ logger }
|
{ logger }
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
|
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
|
||||||
import { ClusterPutComponentTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
|
|
||||||
import { errors as EsErrors } from '@elastic/elasticsearch';
|
import { errors as EsErrors } from '@elastic/elasticsearch';
|
||||||
import { createOrUpdateComponentTemplate } from './create_or_update_component_template';
|
import { createOrUpdateComponentTemplate } from './create_or_update_component_template';
|
||||||
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
|
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
|
||||||
|
@ -14,7 +13,7 @@ const randomDelayMultiplier = 0.01;
|
||||||
const logger = loggingSystemMock.createLogger();
|
const logger = loggingSystemMock.createLogger();
|
||||||
const clusterClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
|
const clusterClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
|
||||||
|
|
||||||
const ComponentTemplate: ClusterPutComponentTemplateRequest = {
|
const ComponentTemplate = {
|
||||||
name: 'test-mappings',
|
name: 'test-mappings',
|
||||||
_meta: {
|
_meta: {
|
||||||
managed: true,
|
managed: true,
|
||||||
|
@ -177,12 +176,14 @@ describe('createOrUpdateComponentTemplate', () => {
|
||||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
||||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
||||||
name: existingIndexTemplate.name,
|
name: existingIndexTemplate.name,
|
||||||
...existingIndexTemplate.index_template,
|
body: {
|
||||||
template: {
|
...existingIndexTemplate.index_template,
|
||||||
...existingIndexTemplate.index_template.template,
|
template: {
|
||||||
settings: {
|
...existingIndexTemplate.index_template.template,
|
||||||
...existingIndexTemplate.index_template.template?.settings,
|
settings: {
|
||||||
'index.mapping.total_fields.limit': 2500,
|
...existingIndexTemplate.index_template.template?.settings,
|
||||||
|
'index.mapping.total_fields.limit': 2500,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -281,12 +282,14 @@ describe('createOrUpdateComponentTemplate', () => {
|
||||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
||||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
||||||
name: existingIndexTemplate.name,
|
name: existingIndexTemplate.name,
|
||||||
...existingIndexTemplate.index_template,
|
body: {
|
||||||
template: {
|
...existingIndexTemplate.index_template,
|
||||||
...existingIndexTemplate.index_template.template,
|
template: {
|
||||||
settings: {
|
...existingIndexTemplate.index_template.template,
|
||||||
...existingIndexTemplate.index_template.template?.settings,
|
settings: {
|
||||||
'index.mapping.total_fields.limit': 2500,
|
...existingIndexTemplate.index_template.template?.settings,
|
||||||
|
'index.mapping.total_fields.limit': 2500,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import {
|
import {
|
||||||
ClusterPutComponentTemplateRequest,
|
ClusterPutComponentTemplateRequest,
|
||||||
IndicesGetIndexTemplateIndexTemplateItem,
|
IndicesGetIndexTemplateIndexTemplateItem,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||||
import { asyncForEach } from '@kbn/std';
|
import { asyncForEach } from '@kbn/std';
|
||||||
import { retryTransientEsErrors } from './retry_transient_es_errors';
|
import { retryTransientEsErrors } from './retry_transient_es_errors';
|
||||||
|
@ -50,12 +50,14 @@ const getIndexTemplatesUsingComponentTemplate = async (
|
||||||
() =>
|
() =>
|
||||||
esClient.indices.putIndexTemplate({
|
esClient.indices.putIndexTemplate({
|
||||||
name: template.name,
|
name: template.name,
|
||||||
...template.index_template,
|
body: {
|
||||||
template: {
|
...template.index_template,
|
||||||
...template.index_template.template,
|
template: {
|
||||||
settings: {
|
...template.index_template.template,
|
||||||
...template.index_template.template?.settings,
|
settings: {
|
||||||
'index.mapping.total_fields.limit': totalFieldsLimit,
|
...template.index_template.template?.settings,
|
||||||
|
'index.mapping.total_fields.limit': totalFieldsLimit,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IlmPolicy } from '@elastic/elasticsearch/lib/api/types';
|
import { IlmPolicy } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||||
import { retryTransientEsErrors } from './retry_transient_es_errors';
|
import { retryTransientEsErrors } from './retry_transient_es_errors';
|
||||||
import { DataStreamAdapter } from './data_stream_adapter';
|
import { DataStreamAdapter } from './data_stream_adapter';
|
||||||
|
|
|
@ -16,42 +16,44 @@ const clusterClient = elasticsearchServiceMock.createClusterClient().asInternalU
|
||||||
|
|
||||||
const IndexTemplate = (namespace: string = 'default', useDataStream: boolean = false) => ({
|
const IndexTemplate = (namespace: string = 'default', useDataStream: boolean = false) => ({
|
||||||
name: `.alerts-test.alerts-${namespace}-index-template`,
|
name: `.alerts-test.alerts-${namespace}-index-template`,
|
||||||
_meta: {
|
body: {
|
||||||
kibana: {
|
_meta: {
|
||||||
version: '8.6.1',
|
kibana: {
|
||||||
},
|
version: '8.6.1',
|
||||||
managed: true,
|
|
||||||
namespace,
|
|
||||||
},
|
|
||||||
composed_of: ['mappings1', 'framework-mappings'],
|
|
||||||
index_patterns: [`.internal.alerts-test.alerts-${namespace}-*`],
|
|
||||||
template: {
|
|
||||||
mappings: {
|
|
||||||
_meta: {
|
|
||||||
kibana: {
|
|
||||||
version: '8.6.1',
|
|
||||||
},
|
|
||||||
managed: true,
|
|
||||||
namespace,
|
|
||||||
},
|
},
|
||||||
dynamic: false,
|
managed: true,
|
||||||
|
namespace,
|
||||||
},
|
},
|
||||||
settings: {
|
composed_of: ['mappings1', 'framework-mappings'],
|
||||||
auto_expand_replicas: '0-1',
|
index_patterns: [`.internal.alerts-test.alerts-${namespace}-*`],
|
||||||
hidden: true,
|
template: {
|
||||||
...(useDataStream
|
mappings: {
|
||||||
? {}
|
_meta: {
|
||||||
: {
|
kibana: {
|
||||||
'index.lifecycle': {
|
version: '8.6.1',
|
||||||
name: 'test-ilm-policy',
|
},
|
||||||
rollover_alias: `.alerts-test.alerts-${namespace}`,
|
managed: true,
|
||||||
},
|
namespace,
|
||||||
}),
|
},
|
||||||
'index.mapping.ignore_malformed': true,
|
dynamic: false,
|
||||||
'index.mapping.total_fields.limit': 2500,
|
},
|
||||||
|
settings: {
|
||||||
|
auto_expand_replicas: '0-1',
|
||||||
|
hidden: true,
|
||||||
|
...(useDataStream
|
||||||
|
? {}
|
||||||
|
: {
|
||||||
|
'index.lifecycle': {
|
||||||
|
name: 'test-ilm-policy',
|
||||||
|
rollover_alias: `.alerts-test.alerts-${namespace}`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
'index.mapping.ignore_malformed': true,
|
||||||
|
'index.mapping.total_fields.limit': 2500,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
priority: namespace.length,
|
||||||
},
|
},
|
||||||
priority: namespace.length,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const SimulateTemplateResponse = {
|
const SimulateTemplateResponse = {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
IndicesPutIndexTemplateRequest,
|
IndicesPutIndexTemplateRequest,
|
||||||
MappingTypeMapping,
|
MappingTypeMapping,
|
||||||
Metadata,
|
Metadata,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import { IIndexPatternString } from '../resource_installer_utils';
|
import { IIndexPatternString } from '../resource_installer_utils';
|
||||||
|
@ -57,40 +57,42 @@ export const getIndexTemplate = ({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: indexPatterns.template,
|
name: indexPatterns.template,
|
||||||
...(dataStreamFields.data_stream ? { data_stream: dataStreamFields.data_stream } : {}),
|
body: {
|
||||||
index_patterns: dataStreamFields.index_patterns,
|
...(dataStreamFields.data_stream ? { data_stream: dataStreamFields.data_stream } : {}),
|
||||||
composed_of: componentTemplateRefs,
|
index_patterns: dataStreamFields.index_patterns,
|
||||||
template: {
|
composed_of: componentTemplateRefs,
|
||||||
settings: {
|
template: {
|
||||||
auto_expand_replicas: '0-1',
|
settings: {
|
||||||
hidden: true,
|
auto_expand_replicas: '0-1',
|
||||||
...(dataStreamAdapter.isUsingDataStreams()
|
hidden: true,
|
||||||
? {}
|
...(dataStreamAdapter.isUsingDataStreams()
|
||||||
: {
|
? {}
|
||||||
'index.lifecycle': indexLifecycle,
|
: {
|
||||||
}),
|
'index.lifecycle': indexLifecycle,
|
||||||
'index.mapping.ignore_malformed': true,
|
}),
|
||||||
'index.mapping.total_fields.limit': totalFieldsLimit,
|
'index.mapping.ignore_malformed': true,
|
||||||
},
|
'index.mapping.total_fields.limit': totalFieldsLimit,
|
||||||
mappings: {
|
},
|
||||||
dynamic: false,
|
mappings: {
|
||||||
_meta: indexMetadata,
|
dynamic: false,
|
||||||
},
|
_meta: indexMetadata,
|
||||||
...(indexPatterns.secondaryAlias
|
},
|
||||||
? {
|
...(indexPatterns.secondaryAlias
|
||||||
aliases: {
|
? {
|
||||||
[indexPatterns.secondaryAlias]: {
|
aliases: {
|
||||||
is_write_index: false,
|
[indexPatterns.secondaryAlias]: {
|
||||||
|
is_write_index: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
: {}),
|
||||||
: {}),
|
},
|
||||||
},
|
_meta: indexMetadata,
|
||||||
_meta: indexMetadata,
|
|
||||||
|
|
||||||
// By setting the priority to namespace.length, we ensure that if one namespace is a prefix of another namespace
|
// By setting the priority to namespace.length, we ensure that if one namespace is a prefix of another namespace
|
||||||
// then newly created indices will use the matching template with the *longest* namespace
|
// then newly created indices will use the matching template with the *longest* namespace
|
||||||
priority: namespace.length,
|
priority: namespace.length,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -208,9 +208,11 @@ async function createAliasStream(opts: CreateConcreteWriteIndexOpts): Promise<vo
|
||||||
() =>
|
() =>
|
||||||
esClient.indices.create({
|
esClient.indices.create({
|
||||||
index: indexPatterns.name,
|
index: indexPatterns.name,
|
||||||
aliases: {
|
body: {
|
||||||
[indexPatterns.alias]: {
|
aliases: {
|
||||||
is_write_index: true,
|
[indexPatterns.alias]: {
|
||||||
|
is_write_index: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -59,45 +59,42 @@ describe('setAlertsToUntracked()', () => {
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"allow_no_indices": true,
|
"allow_no_indices": true,
|
||||||
"conflicts": "proceed",
|
"body": Object {
|
||||||
"index": Array [
|
"conflicts": "proceed",
|
||||||
"test-index",
|
"query": Object {
|
||||||
],
|
"bool": Object {
|
||||||
"query": Object {
|
"must": Array [
|
||||||
"bool": Object {
|
Object {
|
||||||
"must": Array [
|
"term": Object {
|
||||||
Object {
|
"kibana.alert.status": Object {
|
||||||
"term": Object {
|
"value": "active",
|
||||||
"kibana.alert.status": Object {
|
},
|
||||||
"value": "active",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
Object {
|
||||||
Object {
|
"bool": Object {
|
||||||
"bool": Object {
|
"should": Array [
|
||||||
"should": Array [
|
Object {
|
||||||
Object {
|
"term": Object {
|
||||||
"term": Object {
|
"kibana.alert.rule.uuid": Object {
|
||||||
"kibana.alert.rule.uuid": Object {
|
"value": "test-rule",
|
||||||
"value": "test-rule",
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
},
|
Object {
|
||||||
Object {
|
"bool": Object {
|
||||||
"bool": Object {
|
"should": Array [],
|
||||||
"should": Array [],
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
},
|
"script": Object {
|
||||||
"refresh": true,
|
"lang": "painless",
|
||||||
"script": Object {
|
"source": "
|
||||||
"lang": "painless",
|
|
||||||
"source": "
|
|
||||||
if (!ctx._source.containsKey('kibana.alert.status') || ctx._source['kibana.alert.status'].empty) {
|
if (!ctx._source.containsKey('kibana.alert.status') || ctx._source['kibana.alert.status'].empty) {
|
||||||
ctx._source.kibana.alert.status = 'untracked';
|
ctx._source.kibana.alert.status = 'untracked';
|
||||||
ctx._source.kibana.alert.end = '2023-03-28T22:27:28.159Z';
|
ctx._source.kibana.alert.end = '2023-03-28T22:27:28.159Z';
|
||||||
|
@ -107,7 +104,12 @@ describe('setAlertsToUntracked()', () => {
|
||||||
ctx._source['kibana.alert.end'] = '2023-03-28T22:27:28.159Z';
|
ctx._source['kibana.alert.end'] = '2023-03-28T22:27:28.159Z';
|
||||||
ctx._source['kibana.alert.time_range'].lte = '2023-03-28T22:27:28.159Z';
|
ctx._source['kibana.alert.time_range'].lte = '2023-03-28T22:27:28.159Z';
|
||||||
}",
|
}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"index": Array [
|
||||||
|
"test-index",
|
||||||
|
],
|
||||||
|
"refresh": true,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
|
@ -126,45 +128,42 @@ describe('setAlertsToUntracked()', () => {
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"allow_no_indices": true,
|
"allow_no_indices": true,
|
||||||
"conflicts": "proceed",
|
"body": Object {
|
||||||
"index": Array [
|
"conflicts": "proceed",
|
||||||
"test-index",
|
"query": Object {
|
||||||
],
|
"bool": Object {
|
||||||
"query": Object {
|
"must": Array [
|
||||||
"bool": Object {
|
Object {
|
||||||
"must": Array [
|
"term": Object {
|
||||||
Object {
|
"kibana.alert.status": Object {
|
||||||
"term": Object {
|
"value": "active",
|
||||||
"kibana.alert.status": Object {
|
},
|
||||||
"value": "active",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
Object {
|
||||||
Object {
|
"bool": Object {
|
||||||
"bool": Object {
|
"should": Array [],
|
||||||
"should": Array [],
|
},
|
||||||
},
|
},
|
||||||
},
|
Object {
|
||||||
Object {
|
"bool": Object {
|
||||||
"bool": Object {
|
"should": Array [
|
||||||
"should": Array [
|
Object {
|
||||||
Object {
|
"term": Object {
|
||||||
"term": Object {
|
"kibana.alert.uuid": Object {
|
||||||
"kibana.alert.uuid": Object {
|
"value": "test-alert",
|
||||||
"value": "test-alert",
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
},
|
||||||
},
|
},
|
||||||
},
|
"script": Object {
|
||||||
"refresh": true,
|
"lang": "painless",
|
||||||
"script": Object {
|
"source": "
|
||||||
"lang": "painless",
|
|
||||||
"source": "
|
|
||||||
if (!ctx._source.containsKey('kibana.alert.status') || ctx._source['kibana.alert.status'].empty) {
|
if (!ctx._source.containsKey('kibana.alert.status') || ctx._source['kibana.alert.status'].empty) {
|
||||||
ctx._source.kibana.alert.status = 'untracked';
|
ctx._source.kibana.alert.status = 'untracked';
|
||||||
ctx._source.kibana.alert.end = '2023-03-28T22:27:28.159Z';
|
ctx._source.kibana.alert.end = '2023-03-28T22:27:28.159Z';
|
||||||
|
@ -174,7 +173,12 @@ describe('setAlertsToUntracked()', () => {
|
||||||
ctx._source['kibana.alert.end'] = '2023-03-28T22:27:28.159Z';
|
ctx._source['kibana.alert.end'] = '2023-03-28T22:27:28.159Z';
|
||||||
ctx._source['kibana.alert.time_range'].lte = '2023-03-28T22:27:28.159Z';
|
ctx._source['kibana.alert.time_range'].lte = '2023-03-28T22:27:28.159Z';
|
||||||
}",
|
}",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
"index": Array [
|
||||||
|
"test-index",
|
||||||
|
],
|
||||||
|
"refresh": true,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
|
@ -453,59 +457,63 @@ describe('setAlertsToUntracked()', () => {
|
||||||
|
|
||||||
expect(clusterClient.updateByQuery).toHaveBeenCalledWith(
|
expect(clusterClient.updateByQuery).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
query: {
|
body: expect.objectContaining({
|
||||||
bool: {
|
query: {
|
||||||
must: [
|
bool: {
|
||||||
{
|
must: [
|
||||||
term: {
|
{
|
||||||
'kibana.alert.status': {
|
term: {
|
||||||
value: 'active', // This has to be active
|
'kibana.alert.status': {
|
||||||
},
|
value: 'active', // This has to be active
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
filter: [
|
|
||||||
{
|
|
||||||
bool: {
|
|
||||||
must: {
|
|
||||||
term: {
|
|
||||||
'kibana.alert.rule.name': 'test',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
filter: [
|
||||||
|
{
|
||||||
|
bool: {
|
||||||
|
must: {
|
||||||
|
term: {
|
||||||
|
'kibana.alert.rule.name': 'test',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(clusterClient.search).toHaveBeenCalledWith(
|
expect(clusterClient.search).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
query: {
|
body: expect.objectContaining({
|
||||||
bool: {
|
query: {
|
||||||
must: [
|
bool: {
|
||||||
{
|
must: [
|
||||||
term: {
|
{
|
||||||
'kibana.alert.status': {
|
term: {
|
||||||
value: 'untracked', // This has to be untracked
|
'kibana.alert.status': {
|
||||||
},
|
value: 'untracked', // This has to be untracked
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
filter: [
|
|
||||||
{
|
|
||||||
bool: {
|
|
||||||
must: {
|
|
||||||
term: {
|
|
||||||
'kibana.alert.rule.name': 'test',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
filter: [
|
||||||
|
{
|
||||||
|
bool: {
|
||||||
|
must: {
|
||||||
|
term: {
|
||||||
|
'kibana.alert.rule.name': 'test',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -588,30 +596,32 @@ describe('setAlertsToUntracked()', () => {
|
||||||
|
|
||||||
expect(clusterClient.updateByQuery).toHaveBeenCalledWith(
|
expect(clusterClient.updateByQuery).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
query: {
|
body: expect.objectContaining({
|
||||||
bool: {
|
query: {
|
||||||
must: [
|
bool: {
|
||||||
{
|
must: [
|
||||||
term: {
|
{
|
||||||
'kibana.alert.status': {
|
term: {
|
||||||
value: 'active', // This has to be active
|
'kibana.alert.status': {
|
||||||
},
|
value: 'active', // This has to be active
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
filter: [
|
|
||||||
{
|
|
||||||
bool: {
|
|
||||||
must: {
|
|
||||||
term: {
|
|
||||||
'kibana.alert.rule.name': 'test',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
filter: [
|
||||||
|
{
|
||||||
|
bool: {
|
||||||
|
must: {
|
||||||
|
term: {
|
||||||
|
'kibana.alert.rule.name': 'test',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
ALERT_UUID,
|
ALERT_UUID,
|
||||||
AlertStatus,
|
AlertStatus,
|
||||||
} from '@kbn/rule-data-utils';
|
} from '@kbn/rule-data-utils';
|
||||||
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { RulesClientContext } from '../../rules_client';
|
import type { RulesClientContext } from '../../rules_client';
|
||||||
import { AlertingAuthorizationEntity } from '../../authorization/types';
|
import { AlertingAuthorizationEntity } from '../../authorization/types';
|
||||||
|
|
||||||
|
@ -125,12 +125,14 @@ const ensureAuthorizedToUntrack = async (params: SetAlertsToUntrackedParamsWithD
|
||||||
const response = await esClient.search<never, ConsumersAndRuleTypesAggregation>({
|
const response = await esClient.search<never, ConsumersAndRuleTypesAggregation>({
|
||||||
index: indices,
|
index: indices,
|
||||||
allow_no_indices: true,
|
allow_no_indices: true,
|
||||||
size: 0,
|
body: {
|
||||||
query: getUntrackQuery(params, ALERT_STATUS_ACTIVE),
|
size: 0,
|
||||||
aggs: {
|
query: getUntrackQuery(params, ALERT_STATUS_ACTIVE),
|
||||||
ruleTypeIds: {
|
aggs: {
|
||||||
terms: { field: ALERT_RULE_TYPE_ID },
|
ruleTypeIds: {
|
||||||
aggs: { consumers: { terms: { field: ALERT_RULE_CONSUMER } } },
|
terms: { field: ALERT_RULE_TYPE_ID },
|
||||||
|
aggs: { consumers: { terms: { field: ALERT_RULE_CONSUMER } } },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -216,12 +218,14 @@ export async function setAlertsToUntracked(
|
||||||
const response = await esClient.updateByQuery({
|
const response = await esClient.updateByQuery({
|
||||||
index: indices,
|
index: indices,
|
||||||
allow_no_indices: true,
|
allow_no_indices: true,
|
||||||
conflicts: 'proceed',
|
body: {
|
||||||
script: {
|
conflicts: 'proceed',
|
||||||
source: getUntrackUpdatePainlessScript(new Date()),
|
script: {
|
||||||
lang: 'painless',
|
source: getUntrackUpdatePainlessScript(new Date()),
|
||||||
|
lang: 'painless',
|
||||||
|
},
|
||||||
|
query: getUntrackQuery(params, ALERT_STATUS_ACTIVE),
|
||||||
},
|
},
|
||||||
query: getUntrackQuery(params, ALERT_STATUS_ACTIVE),
|
|
||||||
refresh: true,
|
refresh: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -255,9 +259,11 @@ export async function setAlertsToUntracked(
|
||||||
const searchResponse = await esClient.search({
|
const searchResponse = await esClient.search({
|
||||||
index: indices,
|
index: indices,
|
||||||
allow_no_indices: true,
|
allow_no_indices: true,
|
||||||
_source: [ALERT_RULE_UUID, ALERT_UUID],
|
body: {
|
||||||
size: total,
|
_source: [ALERT_RULE_UUID, ALERT_UUID],
|
||||||
query: getUntrackQuery(params, ALERT_STATUS_UNTRACKED),
|
size: total,
|
||||||
|
query: getUntrackQuery(params, ALERT_STATUS_UNTRACKED),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return searchResponse.hits.hits.map((hit) => hit._source) as UntrackedAlertsResult;
|
return searchResponse.hits.hits.map((hit) => hit._source) as UntrackedAlertsResult;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import type { AggregationsAggregationContainer } from '@elastic/elasticsearch/lib/api/types';
|
import type { AggregationsAggregationContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { TypeOf } from '@kbn/config-schema';
|
import { TypeOf } from '@kbn/config-schema';
|
||||||
import { KueryNode } from '@kbn/es-query';
|
import { KueryNode } from '@kbn/es-query';
|
||||||
import { aggregateOptionsSchema } from '../schemas';
|
import { aggregateOptionsSchema } from '../schemas';
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Boom from '@hapi/boom';
|
import Boom from '@hapi/boom';
|
||||||
import type { AggregationsAggregationContainer } from '@elastic/elasticsearch/lib/api/types';
|
import type { AggregationsAggregationContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
const ALLOW_FIELDS = [
|
const ALLOW_FIELDS = [
|
||||||
'alert.attributes.executionStatus.status',
|
'alert.attributes.executionStatus.status',
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import { remove } from 'lodash';
|
import { remove } from 'lodash';
|
||||||
import { EsQueryConfig, nodeBuilder, toElasticsearchQuery, KueryNode } from '@kbn/es-query';
|
import { EsQueryConfig, nodeBuilder, toElasticsearchQuery, KueryNode } from '@kbn/es-query';
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { AuthorizedRuleTypes } from './alerting_authorization';
|
import { AuthorizedRuleTypes } from './alerting_authorization';
|
||||||
|
|
||||||
export enum AlertingAuthorizationFilterType {
|
export enum AlertingAuthorizationFilterType {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
import {
|
import {
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
AggregationsTermsAggregateBase,
|
AggregationsTermsAggregateBase,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE } from '@kbn/actions-plugin/server/constants/saved_objects';
|
import { ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE } from '@kbn/actions-plugin/server/constants/saved_objects';
|
||||||
import { InvalidateAPIKeyResult } from '../rules_client';
|
import { InvalidateAPIKeyResult } from '../rules_client';
|
||||||
import { AlertingConfig } from '../config';
|
import { AlertingConfig } from '../config';
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Sort, FieldSort, SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
import type {
|
||||||
|
Sort,
|
||||||
|
FieldSort,
|
||||||
|
SortCombinations,
|
||||||
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
const getFormattedSort = (sort: SortCombinations) => {
|
const getFormattedSort = (sort: SortCombinations) => {
|
||||||
if (typeof sort === 'string') {
|
if (typeof sort === 'string') {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { KueryNode } from '@kbn/es-query';
|
import { KueryNode } from '@kbn/es-query';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import Boom from '@hapi/boom';
|
import Boom from '@hapi/boom';
|
||||||
import { flatMap, get, isEmpty } from 'lodash';
|
import { flatMap, get, isEmpty } from 'lodash';
|
||||||
import { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/server';
|
import { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/server';
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
|
||||||
import { createWrappedScopedClusterClientFactory } from './wrap_scoped_cluster_client';
|
import { createWrappedScopedClusterClientFactory } from './wrap_scoped_cluster_client';
|
||||||
|
|
||||||
const esQuery = {
|
const esQuery = {
|
||||||
query: { bool: { filter: { range: { '@timestamp': { gte: 0 } } } } },
|
body: { query: { bool: { filter: { range: { '@timestamp': { gte: 0 } } } } } },
|
||||||
};
|
};
|
||||||
const eqlQuery = {
|
const eqlQuery = {
|
||||||
index: 'foo',
|
index: 'foo',
|
||||||
|
@ -20,7 +20,9 @@ const eqlQuery = {
|
||||||
const esqlQueryRequest = {
|
const esqlQueryRequest = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/_query',
|
path: '/_query',
|
||||||
query: 'from .kibana_task_manager',
|
body: {
|
||||||
|
query: 'from .kibana_task_manager',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let logger = loggingSystemMock.create().get();
|
let logger = loggingSystemMock.create().get();
|
||||||
|
@ -71,7 +73,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
||||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {} and 5000ms requestTimeout`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {} and 5000ms requestTimeout`
|
||||||
);
|
);
|
||||||
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
||||||
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"body\":{},\"statusCode\":200,\"headers\":{\"x-elastic-product\":\"Elasticsearch\"},\"warnings\":[],\"meta\":{}}`
|
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"body\":{},\"statusCode\":200,\"headers\":{\"x-elastic-product\":\"Elasticsearch\"},\"warnings\":[],\"meta\":{}}`
|
||||||
|
@ -100,7 +102,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
||||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {} and 5000ms requestTimeout`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {} and 5000ms requestTimeout`
|
||||||
);
|
);
|
||||||
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
||||||
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"body\":{},\"statusCode\":200,\"headers\":{\"x-elastic-product\":\"Elasticsearch\"},\"warnings\":[],\"meta\":{}}`
|
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"body\":{},\"statusCode\":200,\"headers\":{\"x-elastic-product\":\"Elasticsearch\"},\"warnings\":[],\"meta\":{}}`
|
||||||
|
@ -134,7 +136,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {\"ignore\":[404],\"requestTimeout\":10000} and 5000ms requestTimeout`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {\"ignore\":[404],\"requestTimeout\":10000} and 5000ms requestTimeout`
|
||||||
);
|
);
|
||||||
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
||||||
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"body\":{},\"statusCode\":200,\"headers\":{\"x-elastic-product\":\"Elasticsearch\"},\"warnings\":[],\"meta\":{}}`
|
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"body\":{},\"statusCode\":200,\"headers\":{\"x-elastic-product\":\"Elasticsearch\"},\"warnings\":[],\"meta\":{}}`
|
||||||
|
@ -159,11 +161,11 @@ describe('wrapScopedClusterClient', () => {
|
||||||
).rejects.toThrowErrorMatchingInlineSnapshot(`"something went wrong!"`);
|
).rejects.toThrowErrorMatchingInlineSnapshot(`"something went wrong!"`);
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {}`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {}`
|
||||||
);
|
);
|
||||||
expect(logger.trace).not.toHaveBeenCalled();
|
expect(logger.trace).not.toHaveBeenCalled();
|
||||||
expect(logger.warn).toHaveBeenCalledWith(
|
expect(logger.warn).toHaveBeenCalledWith(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {}`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -193,7 +195,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(stats.esSearchDurationMs).toEqual(0);
|
expect(stats.esSearchDurationMs).toEqual(0);
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {}`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {}`
|
||||||
);
|
);
|
||||||
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
||||||
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {}`
|
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {}`
|
||||||
|
@ -228,7 +230,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(stats.esSearchDurationMs).toEqual(999);
|
expect(stats.esSearchDurationMs).toEqual(999);
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {}`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {}`
|
||||||
);
|
);
|
||||||
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).trace[0][0]).toEqual(
|
||||||
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"took\":333}`
|
`result of executing query for rule .test-rule-type:abcdefg in space my-space: {\"took\":333}`
|
||||||
|
@ -256,7 +258,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}} - with options {}`
|
`executing query for rule .test-rule-type:abcdefg in space my-space - {\"body\":{\"query\":{\"bool\":{\"filter\":{\"range\":{\"@timestamp\":{\"gte\":0}}}}}}} - with options {}`
|
||||||
);
|
);
|
||||||
expect(logger.trace).not.toHaveBeenCalled();
|
expect(logger.trace).not.toHaveBeenCalled();
|
||||||
expect(logger.warn).not.toHaveBeenCalled();
|
expect(logger.warn).not.toHaveBeenCalled();
|
||||||
|
@ -457,7 +459,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
'executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {"method":"POST","path":"/_query","query":"from .kibana_task_manager"} - with options {} and 5000ms requestTimeout'
|
'executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {"method":"POST","path":"/_query","body":{"query":"from .kibana_task_manager"}} - with options {} and 5000ms requestTimeout'
|
||||||
);
|
);
|
||||||
expect(logger.warn).not.toHaveBeenCalled();
|
expect(logger.warn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -483,7 +485,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
||||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
'executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {"method":"POST","path":"/_query","query":"from .kibana_task_manager"} - with options {} and 5000ms requestTimeout'
|
'executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {"method":"POST","path":"/_query","body":{"query":"from .kibana_task_manager"}} - with options {} and 5000ms requestTimeout'
|
||||||
);
|
);
|
||||||
expect(logger.warn).not.toHaveBeenCalled();
|
expect(logger.warn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -514,7 +516,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
'executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {"method":"POST","path":"/_query","query":"from .kibana_task_manager"} - with options {"ignore":[404],"requestTimeout":10000} and 5000ms requestTimeout'
|
'executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {"method":"POST","path":"/_query","body":{"query":"from .kibana_task_manager"}} - with options {"ignore":[404],"requestTimeout":10000} and 5000ms requestTimeout'
|
||||||
);
|
);
|
||||||
expect(logger.warn).not.toHaveBeenCalled();
|
expect(logger.warn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -570,7 +572,7 @@ describe('wrapScopedClusterClient', () => {
|
||||||
expect(stats.totalSearchDurationMs).toBeGreaterThan(-1);
|
expect(stats.totalSearchDurationMs).toBeGreaterThan(-1);
|
||||||
|
|
||||||
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
expect(loggingSystemMock.collect(logger).debug[0][0]).toEqual(
|
||||||
`executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {\"method\":\"POST\",\"path\":\"/_query\",\"query\":\"from .kibana_task_manager\"} - with options {}`
|
`executing ES|QL query for rule .test-rule-type:abcdefg in space my-space - {\"method\":\"POST\",\"path\":\"/_query\",\"body\":{\"query\":\"from .kibana_task_manager\"}} - with options {}`
|
||||||
);
|
);
|
||||||
expect(logger.warn).not.toHaveBeenCalled();
|
expect(logger.warn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,7 +23,7 @@ import type {
|
||||||
SearchRequest as SearchRequestWithBody,
|
SearchRequest as SearchRequestWithBody,
|
||||||
AggregationsAggregate,
|
AggregationsAggregate,
|
||||||
EqlSearchRequest as EqlSearchRequestWithBody,
|
EqlSearchRequest as EqlSearchRequestWithBody,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { IScopedClusterClient, ElasticsearchClient, Logger } from '@kbn/core/server';
|
import type { IScopedClusterClient, ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||||
import { SearchMetrics, RuleInfo } from './types';
|
import { SearchMetrics, RuleInfo } from './types';
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import type {
|
import type {
|
||||||
AggregationsKeyedPercentiles,
|
AggregationsKeyedPercentiles,
|
||||||
AggregationsPercentilesAggregateBase,
|
AggregationsPercentilesAggregateBase,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
|
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
|
||||||
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/server';
|
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/server';
|
||||||
import { CoreSetup } from '@kbn/core/server';
|
import { CoreSetup } from '@kbn/core/server';
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { getRequestAbortedSignal } from '@kbn/data-plugin/server';
|
||||||
import { termsAggSuggestions } from '@kbn/unified-search-plugin/server/autocomplete/terms_agg';
|
import { termsAggSuggestions } from '@kbn/unified-search-plugin/server/autocomplete/terms_agg';
|
||||||
import type { ConfigSchema } from '@kbn/unified-search-plugin/server/config';
|
import type { ConfigSchema } from '@kbn/unified-search-plugin/server/config';
|
||||||
import { getKbnServerError, reportServerError } from '@kbn/kibana-utils-plugin/server';
|
import { getKbnServerError, reportServerError } from '@kbn/kibana-utils-plugin/server';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ALERT_RULE_CONSUMER, ALERT_RULE_TYPE_ID, SPACE_IDS } from '@kbn/rule-data-utils';
|
import { ALERT_RULE_CONSUMER, ALERT_RULE_TYPE_ID, SPACE_IDS } from '@kbn/rule-data-utils';
|
||||||
|
|
||||||
import { verifyAccessAndContext } from '../lib';
|
import { verifyAccessAndContext } from '../lib';
|
||||||
|
|
|
@ -14,7 +14,7 @@ import type { ConfigSchema } from '@kbn/unified-search-plugin/server/config';
|
||||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||||
import { getKbnServerError, reportServerError } from '@kbn/kibana-utils-plugin/server';
|
import { getKbnServerError, reportServerError } from '@kbn/kibana-utils-plugin/server';
|
||||||
import { ALERTING_CASES_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server/src/saved_objects_index_pattern';
|
import { ALERTING_CASES_SAVED_OBJECT_INDEX } from '@kbn/core-saved-objects-server/src/saved_objects_index_pattern';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
import { verifyAccessAndContext } from '../lib';
|
import { verifyAccessAndContext } from '../lib';
|
||||||
import { ILicenseState } from '../../lib';
|
import { ILicenseState } from '../../lib';
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { KueryNode } from '@kbn/es-query';
|
import { KueryNode } from '@kbn/es-query';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { SanitizedRuleWithLegacyId } from '../../types';
|
import { SanitizedRuleWithLegacyId } from '../../types';
|
||||||
import { convertEsSortToEventLogSort } from '../../lib';
|
import { convertEsSortToEventLogSort } from '../../lib';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { KueryNode } from '@kbn/es-query';
|
import { KueryNode } from '@kbn/es-query';
|
||||||
import { SanitizedRuleWithLegacyId } from '../../types';
|
import { SanitizedRuleWithLegacyId } from '../../types';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { RulesClient, ConstructorOptions } from '../rules_client';
|
import { RulesClient, ConstructorOptions } from '../rules_client';
|
||||||
import {
|
import {
|
||||||
savedObjectsClientMock,
|
savedObjectsClientMock,
|
||||||
|
|
|
@ -477,7 +477,7 @@ describe('Ad Hoc Task Runner', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: {
|
create: {
|
||||||
_id: UUID,
|
_id: UUID,
|
||||||
|
@ -745,13 +745,13 @@ describe('Ad Hoc Task Runner', () => {
|
||||||
const bulkCall = clusterClient.bulk.mock.calls[0][0];
|
const bulkCall = clusterClient.bulk.mock.calls[0][0];
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][TIMESTAMP]).toEqual(schedule4.runAt);
|
expect(bulkCall.body[1][TIMESTAMP]).toEqual(schedule4.runAt);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][ALERT_START]).toEqual(schedule4.runAt);
|
expect(bulkCall.body[1][ALERT_START]).toEqual(schedule4.runAt);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][ALERT_TIME_RANGE]).toEqual({ gte: schedule4.runAt });
|
expect(bulkCall.body[1][ALERT_TIME_RANGE]).toEqual({ gte: schedule4.runAt });
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][ALERT_RULE_EXECUTION_TIMESTAMP]).toEqual(DATE_1970);
|
expect(bulkCall.body[1][ALERT_RULE_EXECUTION_TIMESTAMP]).toEqual(DATE_1970);
|
||||||
|
|
||||||
expect(internalSavedObjectsRepository.update).toHaveBeenCalledWith(
|
expect(internalSavedObjectsRepository.update).toHaveBeenCalledWith(
|
||||||
AD_HOC_RUN_SAVED_OBJECT_TYPE,
|
AD_HOC_RUN_SAVED_OBJECT_TYPE,
|
||||||
|
@ -852,13 +852,13 @@ describe('Ad Hoc Task Runner', () => {
|
||||||
const bulkCall = clusterClient.bulk.mock.calls[0][0];
|
const bulkCall = clusterClient.bulk.mock.calls[0][0];
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][TIMESTAMP]).toEqual(schedule5.runAt);
|
expect(bulkCall.body[1][TIMESTAMP]).toEqual(schedule5.runAt);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][ALERT_START]).toEqual(schedule5.runAt);
|
expect(bulkCall.body[1][ALERT_START]).toEqual(schedule5.runAt);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][ALERT_TIME_RANGE]).toEqual({ gte: schedule5.runAt });
|
expect(bulkCall.body[1][ALERT_TIME_RANGE]).toEqual({ gte: schedule5.runAt });
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
expect(bulkCall.operations[1][ALERT_RULE_EXECUTION_TIMESTAMP]).toEqual(DATE_1970);
|
expect(bulkCall.body[1][ALERT_RULE_EXECUTION_TIMESTAMP]).toEqual(DATE_1970);
|
||||||
|
|
||||||
expect(internalSavedObjectsRepository.update).toHaveBeenCalledWith(
|
expect(internalSavedObjectsRepository.update).toHaveBeenCalledWith(
|
||||||
AD_HOC_RUN_SAVED_OBJECT_TYPE,
|
AD_HOC_RUN_SAVED_OBJECT_TYPE,
|
||||||
|
|
|
@ -593,7 +593,7 @@ describe('Task Runner', () => {
|
||||||
index: '.alerts-test.alerts-default',
|
index: '.alerts-test.alerts-default',
|
||||||
refresh: 'wait_for',
|
refresh: 'wait_for',
|
||||||
require_alias: !useDataStreamForAlerts,
|
require_alias: !useDataStreamForAlerts,
|
||||||
operations: [
|
body: [
|
||||||
{
|
{
|
||||||
create: {
|
create: {
|
||||||
_id: '5f6aa57d-3e22-484e-bae8-cbed868f4d28',
|
_id: '5f6aa57d-3e22-484e-bae8-cbed868f4d28',
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import type {
|
import type {
|
||||||
AggregationsTermsAggregateBase,
|
AggregationsTermsAggregateBase,
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||||
|
|
||||||
import { NUM_ALERTING_RULE_TYPES } from '../alerting_usage_collector';
|
import { NUM_ALERTING_RULE_TYPES } from '../alerting_usage_collector';
|
||||||
|
@ -38,14 +38,16 @@ export async function getTotalAlertsCountAggregations({
|
||||||
const query = {
|
const query = {
|
||||||
index: AAD_INDEX_PATTERN,
|
index: AAD_INDEX_PATTERN,
|
||||||
size: 0,
|
size: 0,
|
||||||
query: {
|
body: {
|
||||||
match_all: {},
|
query: {
|
||||||
},
|
match_all: {},
|
||||||
aggs: {
|
},
|
||||||
by_rule_type_id: {
|
aggs: {
|
||||||
terms: {
|
by_rule_type_id: {
|
||||||
field: 'kibana.alert.rule.rule_type_id',
|
terms: {
|
||||||
size: NUM_ALERTING_RULE_TYPES,
|
field: 'kibana.alert.rule.rule_type_id',
|
||||||
|
size: NUM_ALERTING_RULE_TYPES,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ import type {
|
||||||
AggregationsTermsAggregateBase,
|
AggregationsTermsAggregateBase,
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
AggregationsBuckets,
|
AggregationsBuckets,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||||
import {
|
import {
|
||||||
NUM_ALERTING_RULE_TYPES,
|
NUM_ALERTING_RULE_TYPES,
|
||||||
|
@ -136,19 +136,21 @@ export async function getExecutionsPerDayCount({
|
||||||
const query = {
|
const query = {
|
||||||
index: eventLogIndex,
|
index: eventLogIndex,
|
||||||
size: 0,
|
size: 0,
|
||||||
query: getProviderAndActionFilterForTimeRange('execute'),
|
body: {
|
||||||
aggs: {
|
query: getProviderAndActionFilterForTimeRange('execute'),
|
||||||
...eventLogAggs,
|
aggs: {
|
||||||
by_rule_type_id: {
|
...eventLogAggs,
|
||||||
terms: {
|
by_rule_type_id: {
|
||||||
field: 'rule.category',
|
terms: {
|
||||||
size: NUM_ALERTING_RULE_TYPES,
|
field: 'rule.category',
|
||||||
|
size: NUM_ALERTING_RULE_TYPES,
|
||||||
|
},
|
||||||
|
aggs: eventLogAggs,
|
||||||
},
|
},
|
||||||
aggs: eventLogAggs,
|
by_execution_status: {
|
||||||
},
|
terms: {
|
||||||
by_execution_status: {
|
field: 'event.outcome',
|
||||||
terms: {
|
},
|
||||||
field: 'event.outcome',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -227,12 +229,14 @@ export async function getExecutionTimeoutsPerDayCount({
|
||||||
const query = {
|
const query = {
|
||||||
index: eventLogIndex,
|
index: eventLogIndex,
|
||||||
size: 0,
|
size: 0,
|
||||||
query: getProviderAndActionFilterForTimeRange('execute-timeout'),
|
body: {
|
||||||
aggs: {
|
query: getProviderAndActionFilterForTimeRange('execute-timeout'),
|
||||||
by_rule_type_id: {
|
aggs: {
|
||||||
terms: {
|
by_rule_type_id: {
|
||||||
field: 'rule.category',
|
terms: {
|
||||||
size: NUM_ALERTING_RULE_TYPES,
|
field: 'rule.category',
|
||||||
|
size: NUM_ALERTING_RULE_TYPES,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
||||||
AggregationsCardinalityAggregate,
|
AggregationsCardinalityAggregate,
|
||||||
AggregationsTermsAggregateBase,
|
AggregationsTermsAggregateBase,
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ElasticsearchClient, Logger, ISavedObjectsRepository } from '@kbn/core/server';
|
import { ElasticsearchClient, Logger, ISavedObjectsRepository } from '@kbn/core/server';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -83,17 +83,18 @@ export async function getTotalCountAggregations({
|
||||||
const query = {
|
const query = {
|
||||||
index: alertIndex,
|
index: alertIndex,
|
||||||
size: 0,
|
size: 0,
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
// Aggregate over all rule saved objects
|
bool: {
|
||||||
filter: [{ term: { type: 'alert' } }],
|
// Aggregate over all rule saved objects
|
||||||
|
filter: [{ term: { type: 'alert' } }],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
runtime_mappings: {
|
||||||
runtime_mappings: {
|
rule_action_count: {
|
||||||
rule_action_count: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
def alert = params._source['alert'];
|
def alert = params._source['alert'];
|
||||||
if (alert != null) {
|
if (alert != null) {
|
||||||
def actions = alert.actions;
|
def actions = alert.actions;
|
||||||
|
@ -103,13 +104,13 @@ export async function getTotalCountAggregations({
|
||||||
emit(0);
|
emit(0);
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
// Convert schedule interval duration string from rule saved object to interval in seconds
|
||||||
// Convert schedule interval duration string from rule saved object to interval in seconds
|
rule_schedule_interval: {
|
||||||
rule_schedule_interval: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
int parsed = 0;
|
int parsed = 0;
|
||||||
if (doc['alert.schedule.interval'].size() > 0) {
|
if (doc['alert.schedule.interval'].size() > 0) {
|
||||||
def interval = doc['alert.schedule.interval'].value;
|
def interval = doc['alert.schedule.interval'].value;
|
||||||
|
@ -139,13 +140,13 @@ export async function getTotalCountAggregations({
|
||||||
}
|
}
|
||||||
emit(parsed);
|
emit(parsed);
|
||||||
`,
|
`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
// Convert throttle interval duration string from rule saved object to interval in seconds
|
||||||
// Convert throttle interval duration string from rule saved object to interval in seconds
|
rule_throttle_interval: {
|
||||||
rule_throttle_interval: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
int parsed = 0;
|
int parsed = 0;
|
||||||
if (doc['alert.throttle'].size() > 0) {
|
if (doc['alert.throttle'].size() > 0) {
|
||||||
def throttle = doc['alert.throttle'].value;
|
def throttle = doc['alert.throttle'].value;
|
||||||
|
@ -175,12 +176,12 @@ export async function getTotalCountAggregations({
|
||||||
}
|
}
|
||||||
emit(parsed);
|
emit(parsed);
|
||||||
`,
|
`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
rule_with_tags: {
|
||||||
rule_with_tags: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
def rule = params._source['alert'];
|
def rule = params._source['alert'];
|
||||||
if (rule != null && rule.tags != null) {
|
if (rule != null && rule.tags != null) {
|
||||||
if (rule.tags.size() > 0) {
|
if (rule.tags.size() > 0) {
|
||||||
|
@ -189,12 +190,12 @@ export async function getTotalCountAggregations({
|
||||||
emit(0);
|
emit(0);
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
rule_snoozed: {
|
||||||
rule_snoozed: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
def rule = params._source['alert'];
|
def rule = params._source['alert'];
|
||||||
if (rule != null && rule.snoozeSchedule != null) {
|
if (rule != null && rule.snoozeSchedule != null) {
|
||||||
if (rule.snoozeSchedule.size() > 0) {
|
if (rule.snoozeSchedule.size() > 0) {
|
||||||
|
@ -203,23 +204,23 @@ export async function getTotalCountAggregations({
|
||||||
emit(0);
|
emit(0);
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
rule_muted: {
|
||||||
rule_muted: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
if (doc['alert.muteAll'].value == true) {
|
if (doc['alert.muteAll'].value == true) {
|
||||||
emit(1);
|
emit(1);
|
||||||
} else {
|
} else {
|
||||||
emit(0);
|
emit(0);
|
||||||
}`,
|
}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
rule_with_muted_alerts: {
|
||||||
rule_with_muted_alerts: {
|
type: 'long',
|
||||||
type: 'long',
|
script: {
|
||||||
script: {
|
source: `
|
||||||
source: `
|
|
||||||
def rule = params._source['alert'];
|
def rule = params._source['alert'];
|
||||||
if (rule != null && rule.mutedInstanceIds != null) {
|
if (rule != null && rule.mutedInstanceIds != null) {
|
||||||
if (rule.mutedInstanceIds.size() > 0) {
|
if (rule.mutedInstanceIds.size() > 0) {
|
||||||
|
@ -228,63 +229,64 @@ export async function getTotalCountAggregations({
|
||||||
emit(0);
|
emit(0);
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
aggs: {
|
||||||
aggs: {
|
by_rule_type_id: {
|
||||||
by_rule_type_id: {
|
terms: {
|
||||||
terms: {
|
field: 'alert.alertTypeId',
|
||||||
field: 'alert.alertTypeId',
|
size: NUM_ALERTING_RULE_TYPES,
|
||||||
size: NUM_ALERTING_RULE_TYPES,
|
},
|
||||||
},
|
},
|
||||||
},
|
max_throttle_time: { max: { field: 'rule_throttle_interval' } },
|
||||||
max_throttle_time: { max: { field: 'rule_throttle_interval' } },
|
min_throttle_time: { min: { field: 'rule_throttle_interval' } },
|
||||||
min_throttle_time: { min: { field: 'rule_throttle_interval' } },
|
avg_throttle_time: { avg: { field: 'rule_throttle_interval' } },
|
||||||
avg_throttle_time: { avg: { field: 'rule_throttle_interval' } },
|
max_interval_time: { max: { field: 'rule_schedule_interval' } },
|
||||||
max_interval_time: { max: { field: 'rule_schedule_interval' } },
|
min_interval_time: { min: { field: 'rule_schedule_interval' } },
|
||||||
min_interval_time: { min: { field: 'rule_schedule_interval' } },
|
avg_interval_time: { avg: { field: 'rule_schedule_interval' } },
|
||||||
avg_interval_time: { avg: { field: 'rule_schedule_interval' } },
|
max_actions_count: { max: { field: 'rule_action_count' } },
|
||||||
max_actions_count: { max: { field: 'rule_action_count' } },
|
min_actions_count: { min: { field: 'rule_action_count' } },
|
||||||
min_actions_count: { min: { field: 'rule_action_count' } },
|
avg_actions_count: { avg: { field: 'rule_action_count' } },
|
||||||
avg_actions_count: { avg: { field: 'rule_action_count' } },
|
by_execution_status: {
|
||||||
by_execution_status: {
|
terms: {
|
||||||
terms: {
|
field: 'alert.executionStatus.status',
|
||||||
field: 'alert.executionStatus.status',
|
},
|
||||||
},
|
},
|
||||||
},
|
by_notify_when: {
|
||||||
by_notify_when: {
|
terms: {
|
||||||
terms: {
|
field: 'alert.notifyWhen',
|
||||||
field: 'alert.notifyWhen',
|
},
|
||||||
},
|
},
|
||||||
},
|
connector_types_by_consumers: {
|
||||||
connector_types_by_consumers: {
|
terms: {
|
||||||
terms: {
|
field: 'alert.consumer',
|
||||||
field: 'alert.consumer',
|
},
|
||||||
},
|
aggs: {
|
||||||
aggs: {
|
actions: {
|
||||||
actions: {
|
nested: {
|
||||||
nested: {
|
path: 'alert.actions',
|
||||||
path: 'alert.actions',
|
},
|
||||||
},
|
aggs: {
|
||||||
aggs: {
|
connector_types: {
|
||||||
connector_types: {
|
terms: {
|
||||||
terms: {
|
field: 'alert.actions.actionTypeId',
|
||||||
field: 'alert.actions.actionTypeId',
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
by_search_type: {
|
||||||
by_search_type: {
|
terms: {
|
||||||
terms: {
|
field: 'alert.params.searchType',
|
||||||
field: 'alert.params.searchType',
|
},
|
||||||
},
|
},
|
||||||
|
sum_rules_with_tags: { sum: { field: 'rule_with_tags' } },
|
||||||
|
sum_rules_snoozed: { sum: { field: 'rule_snoozed' } },
|
||||||
|
sum_rules_muted: { sum: { field: 'rule_muted' } },
|
||||||
|
sum_rules_with_muted_alerts: { sum: { field: 'rule_with_muted_alerts' } },
|
||||||
},
|
},
|
||||||
sum_rules_with_tags: { sum: { field: 'rule_with_tags' } },
|
|
||||||
sum_rules_snoozed: { sum: { field: 'rule_snoozed' } },
|
|
||||||
sum_rules_muted: { sum: { field: 'rule_muted' } },
|
|
||||||
sum_rules_with_muted_alerts: { sum: { field: 'rule_with_muted_alerts' } },
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -437,23 +439,25 @@ export async function getTotalCountInUse({
|
||||||
const query = {
|
const query = {
|
||||||
index: alertIndex,
|
index: alertIndex,
|
||||||
size: 0,
|
size: 0,
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
// Aggregate over only enabled rule saved objects
|
bool: {
|
||||||
filter: [{ term: { type: 'alert' } }, { term: { 'alert.enabled': true } }],
|
// Aggregate over only enabled rule saved objects
|
||||||
},
|
filter: [{ term: { type: 'alert' } }, { term: { 'alert.enabled': true } }],
|
||||||
},
|
|
||||||
aggs: {
|
|
||||||
namespaces_count: { cardinality: { field: 'namespaces' } },
|
|
||||||
by_rule_type_id: {
|
|
||||||
terms: {
|
|
||||||
field: 'alert.alertTypeId',
|
|
||||||
size: NUM_ALERTING_RULE_TYPES,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
by_search_type: {
|
aggs: {
|
||||||
terms: {
|
namespaces_count: { cardinality: { field: 'namespaces' } },
|
||||||
field: 'alert.params.searchType',
|
by_rule_type_id: {
|
||||||
|
terms: {
|
||||||
|
field: 'alert.alertTypeId',
|
||||||
|
size: NUM_ALERTING_RULE_TYPES,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
by_search_type: {
|
||||||
|
terms: {
|
||||||
|
field: 'alert.params.searchType',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
||||||
AggregationsTermsAggregateBase,
|
AggregationsTermsAggregateBase,
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
AggregationsBuckets,
|
AggregationsBuckets,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||||
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
||||||
import { NUM_ALERTING_RULE_TYPES } from '../alerting_usage_collector';
|
import { NUM_ALERTING_RULE_TYPES } from '../alerting_usage_collector';
|
||||||
|
@ -42,54 +42,56 @@ export async function getFailedAndUnrecognizedTasksPerDay({
|
||||||
const query = {
|
const query = {
|
||||||
index: taskManagerIndex,
|
index: taskManagerIndex,
|
||||||
size: 0,
|
size: 0,
|
||||||
query: {
|
body: {
|
||||||
bool: {
|
query: {
|
||||||
must: [
|
bool: {
|
||||||
{
|
must: [
|
||||||
bool: {
|
{
|
||||||
should: [
|
bool: {
|
||||||
{
|
should: [
|
||||||
term: {
|
{
|
||||||
'task.status': 'unrecognized',
|
term: {
|
||||||
|
'task.status': 'unrecognized',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
term: {
|
||||||
term: {
|
'task.status': 'failed',
|
||||||
'task.status': 'failed',
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wildcard: {
|
|
||||||
'task.taskType': {
|
|
||||||
value: 'alerting:*',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
wildcard: {
|
||||||
range: {
|
'task.taskType': {
|
||||||
'task.runAt': {
|
value: 'alerting:*',
|
||||||
gte: 'now-1d',
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
],
|
range: {
|
||||||
},
|
'task.runAt': {
|
||||||
},
|
gte: 'now-1d',
|
||||||
aggs: {
|
},
|
||||||
by_status: {
|
},
|
||||||
terms: {
|
},
|
||||||
field: 'task.status',
|
],
|
||||||
size: 10,
|
|
||||||
},
|
},
|
||||||
aggs: {
|
},
|
||||||
by_task_type: {
|
aggs: {
|
||||||
terms: {
|
by_status: {
|
||||||
field: 'task.taskType',
|
terms: {
|
||||||
// Use number of alerting rule types because we're filtering by 'alerting:'
|
field: 'task.status',
|
||||||
size: NUM_ALERTING_RULE_TYPES,
|
size: 10,
|
||||||
|
},
|
||||||
|
aggs: {
|
||||||
|
by_task_type: {
|
||||||
|
terms: {
|
||||||
|
field: 'task.taskType',
|
||||||
|
// Use number of alerting rule types because we're filtering by 'alerting:'
|
||||||
|
size: NUM_ALERTING_RULE_TYPES,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/types';
|
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
||||||
|
|
||||||
export interface ConnectorsByConsumersBucket {
|
export interface ConnectorsByConsumersBucket {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import {
|
import {
|
||||||
AggregationsBuckets,
|
AggregationsBuckets,
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
||||||
|
|
||||||
export function parseSimpleRuleTypeBucket(
|
export function parseSimpleRuleTypeBucket(
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
export * from '../../common/ui';
|
export * from '../../common/ui';
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { SingleCaseMetricsResponse } from '../../../../../common/types/api';
|
import type { SingleCaseMetricsResponse } from '../../../../../common/types/api';
|
||||||
import type { AggregationBuilder, AggregationResponse } from '../../types';
|
import type { AggregationBuilder, AggregationResponse } from '../../types';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type {
|
import type {
|
||||||
CasesMetricsFeatureField,
|
CasesMetricsFeatureField,
|
||||||
SingleCaseMetricsFeatureField,
|
SingleCaseMetricsFeatureField,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
||||||
SavedObjectsUpdateResponse,
|
SavedObjectsUpdateResponse,
|
||||||
} from '@kbn/core/server';
|
} from '@kbn/core/server';
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { fromKueryExpression } from '@kbn/es-query';
|
import { fromKueryExpression } from '@kbn/es-query';
|
||||||
import { AttachmentAttributesRt, AttachmentType } from '../../../common/types/domain';
|
import { AttachmentAttributesRt, AttachmentType } from '../../../common/types/domain';
|
||||||
import { decodeOrThrow } from '../../common/runtime_types';
|
import { decodeOrThrow } from '../../common/runtime_types';
|
||||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
||||||
SavedObjectsBulkResponse,
|
SavedObjectsBulkResponse,
|
||||||
SavedObjectsFindResponse,
|
SavedObjectsFindResponse,
|
||||||
} from '@kbn/core/server';
|
} from '@kbn/core/server';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { FILE_SO_TYPE } from '@kbn/files-plugin/common';
|
import { FILE_SO_TYPE } from '@kbn/files-plugin/common';
|
||||||
import { isSOError } from '../../../common/error';
|
import { isSOError } from '../../../common/error';
|
||||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type {
|
import type {
|
||||||
Logger,
|
Logger,
|
||||||
SavedObject,
|
SavedObject,
|
||||||
|
|
|
@ -18,7 +18,7 @@ import type {
|
||||||
SavedObjectsBulkDeleteOptions,
|
SavedObjectsBulkDeleteOptions,
|
||||||
} from '@kbn/core/server';
|
} from '@kbn/core/server';
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { nodeBuilder } from '@kbn/es-query';
|
import { nodeBuilder } from '@kbn/es-query';
|
||||||
|
|
||||||
import type { Case, CaseStatuses, User } from '../../../common/types/domain';
|
import type { Case, CaseStatuses, User } from '../../../common/types/domain';
|
||||||
|
|
|
@ -11,7 +11,7 @@ import type {
|
||||||
SavedObjectsRawDoc,
|
SavedObjectsRawDoc,
|
||||||
} from '@kbn/core/server';
|
} from '@kbn/core/server';
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { KueryNode } from '@kbn/es-query';
|
import type { KueryNode } from '@kbn/es-query';
|
||||||
import type { CaseUserActionDeprecatedResponse } from '../../../common/types/api';
|
import type { CaseUserActionDeprecatedResponse } from '../../../common/types/api';
|
||||||
import { UserActionTypes } from '../../../common/types/domain';
|
import { UserActionTypes } from '../../../common/types/domain';
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { reject, isUndefined, isNumber, pick, isEmpty, get } from 'lodash';
|
||||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { fromKueryExpression, toElasticsearchQuery, KueryNode, nodeBuilder } from '@kbn/es-query';
|
import { fromKueryExpression, toElasticsearchQuery, KueryNode, nodeBuilder } from '@kbn/es-query';
|
||||||
import { IEvent, IValidatedEvent, SAVED_OBJECT_REL_PRIMARY } from '../types';
|
import { IEvent, IValidatedEvent, SAVED_OBJECT_REL_PRIMARY } from '../types';
|
||||||
import { AggregateOptionsType, FindOptionsType, QueryOptionsType } from '../event_log_client';
|
import { AggregateOptionsType, FindOptionsType, QueryOptionsType } from '../event_log_client';
|
||||||
|
@ -399,7 +399,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
||||||
pick(queryOptions.findOptions, ['start', 'end', 'filter'])
|
pick(queryOptions.findOptions, ['start', 'end', 'filter'])
|
||||||
);
|
);
|
||||||
|
|
||||||
const body: estypes.SearchRequest = {
|
const body: estypes.SearchRequest['body'] = {
|
||||||
size: perPage,
|
size: perPage,
|
||||||
from: (page - 1) * perPage,
|
from: (page - 1) * perPage,
|
||||||
query,
|
query,
|
||||||
|
@ -443,7 +443,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
||||||
pick(queryOptions.findOptions, ['start', 'end', 'filter'])
|
pick(queryOptions.findOptions, ['start', 'end', 'filter'])
|
||||||
);
|
);
|
||||||
|
|
||||||
const body: estypes.SearchRequest = {
|
const body: estypes.SearchRequest['body'] = {
|
||||||
size: perPage,
|
size: perPage,
|
||||||
from: (page - 1) * perPage,
|
from: (page - 1) * perPage,
|
||||||
query,
|
query,
|
||||||
|
@ -487,7 +487,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
||||||
pick(queryOptions.aggregateOptions, ['start', 'end', 'filter'])
|
pick(queryOptions.aggregateOptions, ['start', 'end', 'filter'])
|
||||||
);
|
);
|
||||||
|
|
||||||
const body: estypes.SearchRequest = {
|
const body: estypes.SearchRequest['body'] = {
|
||||||
size: 0,
|
size: 0,
|
||||||
query,
|
query,
|
||||||
aggs,
|
aggs,
|
||||||
|
@ -523,7 +523,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
||||||
pick(queryOptions.aggregateOptions, ['start', 'end', 'filter'])
|
pick(queryOptions.aggregateOptions, ['start', 'end', 'filter'])
|
||||||
);
|
);
|
||||||
|
|
||||||
const body: estypes.SearchRequest = {
|
const body: estypes.SearchRequest['body'] = {
|
||||||
size: 0,
|
size: 0,
|
||||||
query,
|
query,
|
||||||
aggs,
|
aggs,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { asyncForEach } from '@kbn/std';
|
import { asyncForEach } from '@kbn/std';
|
||||||
import { groupBy } from 'lodash';
|
import { groupBy } from 'lodash';
|
||||||
import pRetry, { FailedAttemptError } from 'p-retry';
|
import pRetry, { FailedAttemptError } from 'p-retry';
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { omit } from 'lodash';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { schema, TypeOf } from '@kbn/config-schema';
|
import { schema, TypeOf } from '@kbn/config-schema';
|
||||||
import { IClusterClient, KibanaRequest } from '@kbn/core/server';
|
import { IClusterClient, KibanaRequest } from '@kbn/core/server';
|
||||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { SpacesServiceStart } from '@kbn/spaces-plugin/server';
|
import { SpacesServiceStart } from '@kbn/spaces-plugin/server';
|
||||||
|
|
||||||
import { KueryNode } from '@kbn/es-query';
|
import { KueryNode } from '@kbn/es-query';
|
||||||
|
|
|
@ -93,8 +93,8 @@ export class ResourceInstaller {
|
||||||
logger,
|
logger,
|
||||||
esClient: clusterClient,
|
esClient: clusterClient,
|
||||||
template: {
|
template: {
|
||||||
...ecsComponentTemplate,
|
|
||||||
name: ECS_COMPONENT_TEMPLATE_NAME,
|
name: ECS_COMPONENT_TEMPLATE_NAME,
|
||||||
|
body: ecsComponentTemplate,
|
||||||
},
|
},
|
||||||
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
||||||
}),
|
}),
|
||||||
|
@ -103,8 +103,8 @@ export class ResourceInstaller {
|
||||||
logger,
|
logger,
|
||||||
esClient: clusterClient,
|
esClient: clusterClient,
|
||||||
template: {
|
template: {
|
||||||
...technicalComponentTemplate,
|
|
||||||
name: TECHNICAL_COMPONENT_TEMPLATE_NAME,
|
name: TECHNICAL_COMPONENT_TEMPLATE_NAME,
|
||||||
|
body: technicalComponentTemplate,
|
||||||
},
|
},
|
||||||
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
||||||
}),
|
}),
|
||||||
|
@ -168,11 +168,13 @@ export class ResourceInstaller {
|
||||||
esClient: clusterClient,
|
esClient: clusterClient,
|
||||||
template: {
|
template: {
|
||||||
name: indexInfo.getComponentTemplateName(ct.name),
|
name: indexInfo.getComponentTemplateName(ct.name),
|
||||||
template: {
|
body: {
|
||||||
settings: ct.settings ?? {},
|
template: {
|
||||||
mappings: ct.mappings,
|
settings: ct.settings ?? {},
|
||||||
|
mappings: ct.mappings,
|
||||||
|
},
|
||||||
|
_meta: ct._meta,
|
||||||
},
|
},
|
||||||
_meta: ct._meta,
|
|
||||||
},
|
},
|
||||||
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { ESSearchRequest } from '@kbn/es-types';
|
import type { ESSearchRequest } from '@kbn/es-types';
|
||||||
|
|
||||||
interface BuildSortedEventsQueryOpts {
|
interface BuildSortedEventsQueryOpts {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { AlertInstanceContext } from '@kbn/alerting-plugin/server';
|
import { AlertInstanceContext } from '@kbn/alerting-plugin/server';
|
||||||
import { EsQueryRuleParams } from './rule_type_params';
|
import { EsQueryRuleParams } from './rule_type_params';
|
||||||
import { Comparator } from '../../../common/comparator_types';
|
import { Comparator } from '../../../common/comparator_types';
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { SearchResponse } from '@elastic/elasticsearch/lib/api/types';
|
import { SearchResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { OnlyEsQueryRuleParams } from './types';
|
import { OnlyEsQueryRuleParams } from './types';
|
||||||
import { EsQueryRuleParams } from './rule_type_params';
|
import { EsQueryRuleParams } from './rule_type_params';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { validateConfig, validateParams } from '@kbn/actions-plugin/server/lib';
|
import { validateConfig, validateParams } from '@kbn/actions-plugin/server/lib';
|
||||||
import { ConnectorUsageCollector } from '@kbn/actions-plugin/server/types';
|
import { ConnectorUsageCollector } from '@kbn/actions-plugin/server/types';
|
||||||
import { actionsMock } from '@kbn/actions-plugin/server/mocks';
|
import { actionsMock } from '@kbn/actions-plugin/server/mocks';
|
||||||
|
@ -202,24 +202,24 @@ describe('execute()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scopedClusterClient.bulk.mock.calls).toMatchInlineSnapshot(`
|
expect(scopedClusterClient.bulk.mock.calls).toMatchInlineSnapshot(`
|
||||||
Array [
|
Array [
|
||||||
Array [
|
Array [
|
||||||
Object {
|
|
||||||
"index": "index-value",
|
|
||||||
"operations": Array [
|
|
||||||
Object {
|
Object {
|
||||||
"index": Object {
|
"body": Array [
|
||||||
"op_type": "create",
|
Object {
|
||||||
},
|
"index": Object {
|
||||||
},
|
"op_type": "create",
|
||||||
Object {
|
},
|
||||||
"jim": "bob",
|
},
|
||||||
|
Object {
|
||||||
|
"jim": "bob",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"index": "index-value",
|
||||||
|
"refresh": false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"refresh": false,
|
]
|
||||||
},
|
|
||||||
],
|
|
||||||
]
|
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// full params
|
// full params
|
||||||
|
@ -247,30 +247,30 @@ describe('execute()', () => {
|
||||||
|
|
||||||
const calls = scopedClusterClient.bulk.mock.calls;
|
const calls = scopedClusterClient.bulk.mock.calls;
|
||||||
const timeValue = (
|
const timeValue = (
|
||||||
(calls[0][0] as estypes.BulkRequest)?.operations?.[1] as Record<string, unknown>
|
((calls[0][0] as estypes.BulkRequest)?.body as unknown[])[1] as Record<string, unknown>
|
||||||
).field_to_use_for_time;
|
).field_to_use_for_time;
|
||||||
expect(timeValue).toBeInstanceOf(Date);
|
expect(timeValue).toBeInstanceOf(Date);
|
||||||
delete ((calls[0][0] as estypes.BulkRequest)?.operations?.[1] as Record<string, unknown>)
|
delete (((calls[0][0] as estypes.BulkRequest)?.body as unknown[])[1] as Record<string, unknown>)
|
||||||
.field_to_use_for_time;
|
.field_to_use_for_time;
|
||||||
expect(calls).toMatchInlineSnapshot(`
|
expect(calls).toMatchInlineSnapshot(`
|
||||||
Array [
|
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Array [
|
||||||
"index": "index-value",
|
Object {
|
||||||
"operations": Array [
|
"body": Array [
|
||||||
Object {
|
Object {
|
||||||
"index": Object {
|
"index": Object {
|
||||||
"op_type": "create",
|
"op_type": "create",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
Object {
|
||||||
Object {
|
"jimbob": "jr",
|
||||||
"jimbob": "jr",
|
},
|
||||||
},
|
],
|
||||||
],
|
"index": "index-value",
|
||||||
"refresh": true,
|
"refresh": true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// minimal params
|
// minimal params
|
||||||
|
@ -301,8 +301,7 @@ describe('execute()', () => {
|
||||||
Array [
|
Array [
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"index": "index-value",
|
"body": Array [
|
||||||
"operations": Array [
|
|
||||||
Object {
|
Object {
|
||||||
"index": Object {
|
"index": Object {
|
||||||
"op_type": "create",
|
"op_type": "create",
|
||||||
|
@ -312,6 +311,7 @@ describe('execute()', () => {
|
||||||
"jim": "bob",
|
"jim": "bob",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"index": "index-value",
|
||||||
"refresh": false,
|
"refresh": false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -342,32 +342,32 @@ describe('execute()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scopedClusterClient.bulk.mock.calls).toMatchInlineSnapshot(`
|
expect(scopedClusterClient.bulk.mock.calls).toMatchInlineSnapshot(`
|
||||||
Array [
|
Array [
|
||||||
Array [
|
Array [
|
||||||
Object {
|
|
||||||
"index": "index-value",
|
|
||||||
"operations": Array [
|
|
||||||
Object {
|
Object {
|
||||||
"index": Object {
|
"body": Array [
|
||||||
"op_type": "create",
|
Object {
|
||||||
},
|
"index": Object {
|
||||||
},
|
"op_type": "create",
|
||||||
Object {
|
},
|
||||||
"a": 1,
|
},
|
||||||
},
|
Object {
|
||||||
Object {
|
"a": 1,
|
||||||
"index": Object {
|
},
|
||||||
"op_type": "create",
|
Object {
|
||||||
},
|
"index": Object {
|
||||||
},
|
"op_type": "create",
|
||||||
Object {
|
},
|
||||||
"b": 2,
|
},
|
||||||
|
Object {
|
||||||
|
"b": 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"index": "index-value",
|
||||||
|
"refresh": false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"refresh": false,
|
]
|
||||||
},
|
|
||||||
],
|
|
||||||
]
|
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,10 @@ import {
|
||||||
ALERT_HISTORY_PREFIX,
|
ALERT_HISTORY_PREFIX,
|
||||||
buildAlertHistoryDocument,
|
buildAlertHistoryDocument,
|
||||||
} from '@kbn/actions-plugin/common';
|
} from '@kbn/actions-plugin/common';
|
||||||
import { BulkOperationType, BulkResponseItem } from '@elastic/elasticsearch/lib/api/types';
|
import {
|
||||||
|
BulkOperationType,
|
||||||
|
BulkResponseItem,
|
||||||
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
export type ESIndexConnectorType = ConnectorType<
|
export type ESIndexConnectorType = ConnectorType<
|
||||||
ConnectorTypeConfigType,
|
ConnectorTypeConfigType,
|
||||||
|
@ -105,20 +108,20 @@ async function executor(
|
||||||
const { actionId, config, params, services, logger } = execOptions;
|
const { actionId, config, params, services, logger } = execOptions;
|
||||||
const index = params.indexOverride || config.index;
|
const index = params.indexOverride || config.index;
|
||||||
|
|
||||||
const operations = [];
|
const bulkBody = [];
|
||||||
for (const document of params.documents) {
|
for (const document of params.documents) {
|
||||||
const timeField = config.executionTimeField == null ? '' : config.executionTimeField.trim();
|
const timeField = config.executionTimeField == null ? '' : config.executionTimeField.trim();
|
||||||
if (timeField !== '') {
|
if (timeField !== '') {
|
||||||
document[timeField] = new Date();
|
document[timeField] = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
operations.push({ index: { op_type: 'create' } });
|
bulkBody.push({ index: { op_type: 'create' } });
|
||||||
operations.push(document);
|
bulkBody.push(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bulkParams = {
|
const bulkParams = {
|
||||||
index,
|
index,
|
||||||
operations,
|
body: bulkBody,
|
||||||
refresh: config.refresh,
|
refresh: config.refresh,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { Logger } from '@kbn/core/server';
|
import { Logger } from '@kbn/core/server';
|
||||||
import { map } from 'lodash';
|
import { map } from 'lodash';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Subject, race, from } from 'rxjs';
|
import { Subject, race, from } from 'rxjs';
|
||||||
import { bufferWhen, filter, bufferCount, flatMap, mapTo, first } from 'rxjs';
|
import { bufferWhen, filter, bufferCount, flatMap, mapTo, first } from 'rxjs';
|
||||||
import { SavedObjectError } from '@kbn/core-saved-objects-common';
|
import { SavedObjectError } from '@kbn/core-saved-objects-common';
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
AggregationsStringTermsBucket,
|
AggregationsStringTermsBucket,
|
||||||
AggregationsStringTermsBucketKeys,
|
AggregationsStringTermsBucketKeys,
|
||||||
AggregationsTermsAggregateBase,
|
AggregationsTermsAggregateBase,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { TaskStore } from '../task_store';
|
import { TaskStore } from '../task_store';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { times } from 'lodash';
|
||||||
import { taskStoreMock } from '../task_store.mock';
|
import { taskStoreMock } from '../task_store.mock';
|
||||||
import { of, Subject } from 'rxjs';
|
import { of, Subject } from 'rxjs';
|
||||||
import { sleep } from '../test_utils';
|
import { sleep } from '../test_utils';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { TaskTypeDictionary } from '../task_type_dictionary';
|
import { TaskTypeDictionary } from '../task_type_dictionary';
|
||||||
|
|
||||||
type ResponseWithAggs = Omit<estypes.SearchResponse<ConcreteTaskInstance>, 'aggregations'> & {
|
type ResponseWithAggs = Omit<estypes.SearchResponse<ConcreteTaskInstance>, 'aggregations'> & {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { mergeMap, map, filter, switchMap, catchError } from 'rxjs';
|
||||||
import { Logger } from '@kbn/core/server';
|
import { Logger } from '@kbn/core/server';
|
||||||
import { JsonObject } from '@kbn/utility-types';
|
import { JsonObject } from '@kbn/utility-types';
|
||||||
import { keyBy, mapValues } from 'lodash';
|
import { keyBy, mapValues } from 'lodash';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { AggregationResultOf } from '@kbn/es-types';
|
import type { AggregationResultOf } from '@kbn/es-types';
|
||||||
import { AggregatedStatProvider } from '../lib/runtime_statistics_aggregator';
|
import { AggregatedStatProvider } from '../lib/runtime_statistics_aggregator';
|
||||||
import { parseIntervalAsSecond, asInterval, parseIntervalAsMillisecond } from '../lib/intervals';
|
import { parseIntervalAsSecond, asInterval, parseIntervalAsMillisecond } from '../lib/intervals';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { combineLatest, Observable, Subject, BehaviorSubject } from 'rxjs';
|
import { combineLatest, Observable, Subject, BehaviorSubject } from 'rxjs';
|
||||||
import { map, distinctUntilChanged } from 'rxjs';
|
import { map, distinctUntilChanged } from 'rxjs';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type {
|
import type {
|
||||||
UsageCollectionSetup,
|
UsageCollectionSetup,
|
||||||
UsageCollectionStart,
|
UsageCollectionStart,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import type {
|
||||||
AggregationsAggregationContainer,
|
AggregationsAggregationContainer,
|
||||||
QueryDslQueryContainer,
|
QueryDslQueryContainer,
|
||||||
MappingRuntimeFields,
|
MappingRuntimeFields,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import {
|
import {
|
||||||
IdleTaskWithExpiredRunAt,
|
IdleTaskWithExpiredRunAt,
|
||||||
RunningOrClaimingTaskWithExpiredRetryAt,
|
RunningOrClaimingTaskWithExpiredRetryAt,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { TaskTypeDictionary } from '../task_type_dictionary';
|
import { TaskTypeDictionary } from '../task_type_dictionary';
|
||||||
import { TaskStatus, TaskPriority, ConcreteTaskInstance } from '../task';
|
import { TaskStatus, TaskPriority, ConcreteTaskInstance } from '../task';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
export interface MustCondition {
|
export interface MustCondition {
|
||||||
bool: Pick<estypes.QueryDslBoolQuery, 'must'>;
|
bool: Pick<estypes.QueryDslBoolQuery, 'must'>;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import { mockLogger } from '../test_utils';
|
import { mockLogger } from '../test_utils';
|
||||||
import { coreMock, elasticsearchServiceMock } from '@kbn/core/server/mocks';
|
import { coreMock, elasticsearchServiceMock } from '@kbn/core/server/mocks';
|
||||||
import { SCHEDULE_INTERVAL, taskRunner } from './mark_removed_tasks_as_unrecognized';
|
import { SCHEDULE_INTERVAL, taskRunner } from './mark_removed_tasks_as_unrecognized';
|
||||||
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
import { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
const createTaskDoc = (id: string = '1'): SearchHit<unknown> => ({
|
const createTaskDoc = (id: string = '1'): SearchHit<unknown> => ({
|
||||||
_index: '.kibana_task_manager_9.0.0_001',
|
_index: '.kibana_task_manager_9.0.0_001',
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import { Logger } from '@kbn/logging';
|
import { Logger } from '@kbn/logging';
|
||||||
import { CoreStart } from '@kbn/core-lifecycle-server';
|
import { CoreStart } from '@kbn/core-lifecycle-server';
|
||||||
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||||
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
import { SearchHit } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { TaskScheduling } from '../task_scheduling';
|
import { TaskScheduling } from '../task_scheduling';
|
||||||
import { TaskTypeDictionary } from '../task_type_dictionary';
|
import { TaskTypeDictionary } from '../task_type_dictionary';
|
||||||
import { ConcreteTaskInstance, TaskManagerStartContract } from '..';
|
import { ConcreteTaskInstance, TaskManagerStartContract } from '..';
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/us
|
||||||
import { MonitoringStats } from '../monitoring';
|
import { MonitoringStats } from '../monitoring';
|
||||||
import { configSchema, TaskManagerConfig } from '../config';
|
import { configSchema, TaskManagerConfig } from '../config';
|
||||||
import { backgroundTaskUtilizationRoute } from './background_task_utilization';
|
import { backgroundTaskUtilizationRoute } from './background_task_utilization';
|
||||||
import { SecurityHasPrivilegesResponse } from '@elastic/elasticsearch/lib/api/types';
|
import { SecurityHasPrivilegesResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { SavedObjectsServiceSetup } from '@kbn/core/server';
|
import type { SavedObjectsServiceSetup } from '@kbn/core/server';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { backgroundTaskNodeMapping, taskMappings } from './mappings';
|
import { backgroundTaskNodeMapping, taskMappings } from './mappings';
|
||||||
import { getMigrations } from './migrations';
|
import { getMigrations } from './migrations';
|
||||||
import { TaskManagerConfig } from '../config';
|
import { TaskManagerConfig } from '../config';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { schema } from '@kbn/config-schema';
|
import { schema } from '@kbn/config-schema';
|
||||||
import { Client } from '@elastic/elasticsearch';
|
import { Client } from '@elastic/elasticsearch';
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { first } from 'rxjs';
|
import { first } from 'rxjs';
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { Subject } from 'rxjs';
|
||||||
import { omit, defaults, get } from 'lodash';
|
import { omit, defaults, get } from 'lodash';
|
||||||
import { SavedObjectError } from '@kbn/core-saved-objects-common';
|
import { SavedObjectError } from '@kbn/core-saved-objects-common';
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { SavedObjectsBulkDeleteResponse, Logger } from '@kbn/core/server';
|
import type { SavedObjectsBulkDeleteResponse, Logger } from '@kbn/core/server';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import { AggregationsAggregationContainer } from '@elastic/elasticsearch/lib/api/types';
|
import { AggregationsAggregationContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { DateRangeInfo, getDateRangeInfo } from './date_range_info';
|
import { DateRangeInfo, getDateRangeInfo } from './date_range_info';
|
||||||
|
|
||||||
export interface BuildAggregationOpts {
|
export interface BuildAggregationOpts {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
SearchHit,
|
SearchHit,
|
||||||
SearchHitsMetadata,
|
SearchHitsMetadata,
|
||||||
AggregationsSingleMetricAggregateBase,
|
AggregationsSingleMetricAggregateBase,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { Group } from '@kbn/observability-alerting-rule-utils';
|
import type { Group } from '@kbn/observability-alerting-rule-utils';
|
||||||
|
|
||||||
export const UngroupedGroupId = 'all documents';
|
export const UngroupedGroupId = 'all documents';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { HttpSetup } from '@kbn/core/public';
|
import { HttpSetup } from '@kbn/core/public';
|
||||||
import type { SortOrder } from '@elastic/elasticsearch/lib/api/types';
|
import type { SortOrder } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import {
|
import {
|
||||||
IExecutionLog,
|
IExecutionLog,
|
||||||
ExecutionLogSortFields,
|
ExecutionLogSortFields,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { HttpSetup } from '@kbn/core/public';
|
import { HttpSetup } from '@kbn/core/public';
|
||||||
import type { SortOrder } from '@elastic/elasticsearch/lib/api/types';
|
import type { SortOrder } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { IExecutionErrorsResult, ActionErrorLogSortFields } from '@kbn/alerting-plugin/common';
|
import { IExecutionErrorsResult, ActionErrorLogSortFields } from '@kbn/alerting-plugin/common';
|
||||||
import { INTERNAL_BASE_ALERTING_API_PATH } from '../../constants';
|
import { INTERNAL_BASE_ALERTING_API_PATH } from '../../constants';
|
||||||
import { getFilter } from './get_filter';
|
import { getFilter } from './get_filter';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
import { HttpSetup } from '@kbn/core/public';
|
import { HttpSetup } from '@kbn/core/public';
|
||||||
import type { SortOrder } from '@elastic/elasticsearch/lib/api/types';
|
import type { SortOrder } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import {
|
import {
|
||||||
IExecutionLog,
|
IExecutionLog,
|
||||||
ExecutionLogSortFields,
|
ExecutionLogSortFields,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
EuiCopy,
|
EuiCopy,
|
||||||
EuiDataGridControlColumn,
|
EuiDataGridControlColumn,
|
||||||
} from '@elastic/eui';
|
} from '@elastic/eui';
|
||||||
import type { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types';
|
import type { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { ALERT_CASE_IDS, ALERT_MAINTENANCE_WINDOW_IDS } from '@kbn/rule-data-utils';
|
import { ALERT_CASE_IDS, ALERT_MAINTENANCE_WINDOW_IDS } from '@kbn/rule-data-utils';
|
||||||
import type { RuleRegistrySearchRequestPagination } from '@kbn/rule-registry-plugin/common';
|
import type { RuleRegistrySearchRequestPagination } from '@kbn/rule-registry-plugin/common';
|
||||||
import type { BrowserFields } from '@kbn/alerting-types';
|
import type { BrowserFields } from '@kbn/alerting-types';
|
||||||
|
@ -27,7 +27,7 @@ import { Storage } from '@kbn/kibana-utils-plugin/public';
|
||||||
import type {
|
import type {
|
||||||
QueryDslQueryContainer,
|
QueryDslQueryContainer,
|
||||||
SortCombinations,
|
SortCombinations,
|
||||||
} from '@elastic/elasticsearch/lib/api/types';
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
import { useSearchAlertsQuery } from '@kbn/alerts-ui-shared/src/common/hooks/use_search_alerts_query';
|
import { useSearchAlertsQuery } from '@kbn/alerts-ui-shared/src/common/hooks/use_search_alerts_query';
|
||||||
import { DEFAULT_ALERTS_PAGE_SIZE } from '@kbn/alerts-ui-shared/src/common/constants';
|
import { DEFAULT_ALERTS_PAGE_SIZE } from '@kbn/alerts-ui-shared/src/common/constants';
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
ALERT_STATUS,
|
ALERT_STATUS,
|
||||||
TIMESTAMP,
|
TIMESTAMP,
|
||||||
} from '@kbn/rule-data-utils';
|
} from '@kbn/rule-data-utils';
|
||||||
import { SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
import { SortCombinations } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common';
|
import { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { FEATURE_LABEL } from '../translations';
|
import { FEATURE_LABEL } from '../translations';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
import type { SortCombinations } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
|
|
||||||
export const DefaultSort: SortCombinations[] = [
|
export const DefaultSort: SortCombinations[] = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
import { useCallback, useContext, useEffect, useMemo } from 'react';
|
import { useCallback, useContext, useEffect, useMemo } from 'react';
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||||
import { ALERT_CASE_IDS, isSiemRuleType } from '@kbn/rule-data-utils';
|
import { ALERT_CASE_IDS, isSiemRuleType } from '@kbn/rule-data-utils';
|
||||||
import { AlertsTableContext } from '../contexts/alerts_table_context';
|
import { AlertsTableContext } from '../contexts/alerts_table_context';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { INTERNAL_BASE_ALERTING_API_PATH } from '@kbn/alerting-plugin/common';
|
import { INTERNAL_BASE_ALERTING_API_PATH } from '@kbn/alerting-plugin/common';
|
||||||
import { AlertsQueryContext } from '@kbn/alerts-ui-shared/src/common/contexts/alerts_query_context';
|
import { AlertsQueryContext } from '@kbn/alerts-ui-shared/src/common/contexts/alerts_query_context';
|
||||||
import { useKibana } from '../../../../common';
|
import { useKibana } from '../../../../common';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
import type { SortCombinations } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type { EuiDataGridSorting } from '@elastic/eui';
|
import type { EuiDataGridSorting } from '@elastic/eui';
|
||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types';
|
import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { BrowserFields } from '@kbn/rule-registry-plugin/common';
|
import { BrowserFields } from '@kbn/rule-registry-plugin/common';
|
||||||
|
|
||||||
const DEFAULT_INDEX_PATTERN = [
|
const DEFAULT_INDEX_PATTERN = [
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { QueryDslQueryContainer, SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
import {
|
||||||
|
QueryDslQueryContainer,
|
||||||
|
SortCombinations,
|
||||||
|
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import type {
|
import type {
|
||||||
EuiDataGridCellPopoverElementProps,
|
EuiDataGridCellPopoverElementProps,
|
||||||
EuiDataGridCellProps,
|
EuiDataGridCellProps,
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { loggingSystemMock } from '@kbn/core/server/mocks';
|
import { loggingSystemMock } from '@kbn/core/server/mocks';
|
||||||
import { Logger } from '@kbn/core/server';
|
import { Logger } from '@kbn/core/server';
|
||||||
import { TimeSeriesQuery, timeSeriesQuery, getResultFromEs } from './time_series_query';
|
import { TimeSeriesQuery, timeSeriesQuery, getResultFromEs } from './time_series_query';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* 2.0.
|
* 2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||||
import { Logger } from '@kbn/core/server';
|
import { Logger } from '@kbn/core/server';
|
||||||
import type { ElasticsearchClient } from '@kbn/core/server';
|
import type { ElasticsearchClient } from '@kbn/core/server';
|
||||||
import { getEsErrorMessage } from '@kbn/alerting-plugin/server';
|
import { getEsErrorMessage } from '@kbn/alerting-plugin/server';
|
||||||
|
|
|
@ -181,12 +181,14 @@ const assertIndexTemplate = (namespace: string) => {
|
||||||
expect(createOrUpdateIndexTemplate).toHaveBeenCalledWith({
|
expect(createOrUpdateIndexTemplate).toHaveBeenCalledWith({
|
||||||
logger,
|
logger,
|
||||||
esClient,
|
esClient,
|
||||||
template: expect.objectContaining({
|
template: {
|
||||||
name: `.risk-score.risk-score-${namespace}-index-template`,
|
name: `.risk-score.risk-score-${namespace}-index-template`,
|
||||||
data_stream: { hidden: true },
|
body: expect.objectContaining({
|
||||||
index_patterns: [`risk-score.risk-score-${namespace}`],
|
data_stream: { hidden: true },
|
||||||
composed_of: [`.risk-score-mappings-${namespace}`],
|
index_patterns: [`risk-score.risk-score-${namespace}`],
|
||||||
}),
|
composed_of: [`.risk-score-mappings-${namespace}`],
|
||||||
|
}),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue