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,
|
||||
QueryDslQueryContainer,
|
||||
SortCombinations,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { Alert } from './alert_type';
|
||||
|
||||
export type RuleRegistrySearchRequest = IEsSearchRequest & {
|
||||
|
|
|
@ -20,7 +20,7 @@ import type {
|
|||
QueryDslFieldAndFormat,
|
||||
QueryDslQueryContainer,
|
||||
SortCombinations,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { EsQuerySnapshot, LegacyField } from '../../types';
|
||||
|
||||
export interface SearchAlertsParams {
|
||||
|
|
|
@ -16,7 +16,7 @@ import type {
|
|||
AggregationsAggregationContainer,
|
||||
QueryDslQueryContainer,
|
||||
SortCombinations,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { BASE_RAC_ALERTS_API_PATH } from '../constants';
|
||||
|
||||
export interface UseGetAlertsGroupAggregationsQueryProps {
|
||||
|
|
|
@ -11,10 +11,10 @@ import type {
|
|||
Script,
|
||||
MappingRuntimeField,
|
||||
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 { 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 =
|
||||
| Record<string, Omit<RuntimeFieldSpec, 'type'> & { type: RuntimePrimitiveTypes }>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/**
|
||||
* 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 { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||
import { omit } from 'lodash';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { SavedObjectsClient } from '@kbn/core/server';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { flatMap, get, isEmpty } from 'lodash';
|
||||
import { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/server';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import type {
|
||||
AggregationsKeyedPercentiles,
|
||||
AggregationsPercentilesAggregateBase,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
|
||||
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/server';
|
||||
import { CoreSetup } from '@kbn/core/server';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||
import { AggregationsTermsAggregateBase } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { AggregationsTermsAggregateBase } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import {
|
||||
AvgActionRunOutcomeByConnectorTypeBucket,
|
||||
parseActionRunOutcomeByConnectorTypesBucket,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { replaceFirstAndLastDotSymbols } from '../actions_telemetry';
|
||||
|
||||
export interface AvgActionRunOutcomeByConnectorTypeBucket {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 type { FieldMap, MultiField } from '@kbn/alerts-as-data-utils';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import type {
|
||||
AggregationsAggregationContainer,
|
||||
AggregationsCompositeAggregation,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { AggregateOptions } from '../server/application/rule/methods/aggregate/types';
|
||||
|
||||
export type RuleTagsAggregationOptions = Pick<AggregateOptions, 'filter' | 'search'> & {
|
||||
|
|
|
@ -442,6 +442,7 @@ describe('Alerts Client', () => {
|
|||
);
|
||||
|
||||
expect(clusterClient.search).toHaveBeenCalledWith({
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
|
@ -452,6 +453,7 @@ describe('Alerts Client', () => {
|
|||
},
|
||||
seq_no_primary_term: true,
|
||||
size: 3,
|
||||
},
|
||||
index: useDataStreamForAlerts
|
||||
? '.alerts-test.alerts-default'
|
||||
: '.internal.alerts-test.alerts-default-*',
|
||||
|
@ -514,6 +516,7 @@ describe('Alerts Client', () => {
|
|||
);
|
||||
|
||||
expect(clusterClient.search).toHaveBeenCalledWith({
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
|
@ -524,6 +527,7 @@ describe('Alerts Client', () => {
|
|||
},
|
||||
size: 1,
|
||||
seq_no_primary_term: true,
|
||||
},
|
||||
index: useDataStreamForAlerts
|
||||
? '.alerts-test.alerts-default'
|
||||
: '.internal.alerts-test.alerts-default-*',
|
||||
|
@ -566,7 +570,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
||||
},
|
||||
|
@ -613,7 +617,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: true,
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
||||
},
|
||||
|
@ -706,7 +710,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'abc',
|
||||
|
@ -779,7 +783,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'abc',
|
||||
|
@ -914,7 +918,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: {
|
||||
_id: 'abc',
|
||||
|
@ -987,7 +991,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'def',
|
||||
|
@ -1086,7 +1090,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'def',
|
||||
|
@ -1243,7 +1247,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'def',
|
||||
|
@ -1361,7 +1365,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'def',
|
||||
|
@ -1565,7 +1569,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'def',
|
||||
|
@ -2536,7 +2540,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
|
||||
},
|
||||
|
@ -2810,7 +2814,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: {
|
||||
_id: expect.any(String),
|
||||
|
@ -2911,7 +2915,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: {
|
||||
_id: 'abc',
|
||||
|
@ -3008,7 +3012,7 @@ describe('Alerts Client', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
index: {
|
||||
_id: 'abc',
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
ALERT_MAINTENANCE_WINDOW_IDS,
|
||||
} from '@kbn/rule-data-utils';
|
||||
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 { DEFAULT_NAMESPACE_STRING } from '@kbn/core-saved-objects-utils-server';
|
||||
import { DeepPartial } from '@kbn/utility-types';
|
||||
|
@ -231,7 +231,7 @@ export class AlertsClient<
|
|||
}
|
||||
|
||||
public async search<Aggregation = unknown>(
|
||||
queryBody: SearchRequest
|
||||
queryBody: SearchRequest['body']
|
||||
): Promise<SearchResult<AlertData, Aggregation>> {
|
||||
const esClient = await this.options.elasticsearchClientPromise;
|
||||
const index = this.isUsingDataStreams()
|
||||
|
@ -242,7 +242,7 @@ export class AlertsClient<
|
|||
aggregations,
|
||||
} = await esClient.search<Alert & AlertData, Aggregation>({
|
||||
index,
|
||||
...queryBody,
|
||||
body: queryBody,
|
||||
ignore_unavailable: true,
|
||||
});
|
||||
|
||||
|
@ -568,7 +568,7 @@ export class AlertsClient<
|
|||
refresh: this.isServerless ? true : 'wait_for',
|
||||
index: this.indexTemplateAndPattern.alias,
|
||||
require_alias: !this.isUsingDataStreams(),
|
||||
operations: bulkBody,
|
||||
body: bulkBody,
|
||||
});
|
||||
|
||||
// If there were individual indexing errors, they will be returned in the success response
|
||||
|
|
|
@ -129,6 +129,7 @@ export const getExpectedQueryByExecutionUuid = ({
|
|||
excludedAlertInstanceIds?: string[];
|
||||
alertsFilter?: AlertsFilter;
|
||||
}) => ({
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
|
@ -220,6 +221,7 @@ export const getExpectedQueryByExecutionUuid = ({
|
|||
},
|
||||
size: 100,
|
||||
track_total_hits: true,
|
||||
},
|
||||
ignore_unavailable: true,
|
||||
index: indexName,
|
||||
});
|
||||
|
@ -374,6 +376,7 @@ export const getExpectedQueryByTimeRange = ({
|
|||
}
|
||||
|
||||
return {
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter,
|
||||
|
@ -381,6 +384,7 @@ export const getExpectedQueryByTimeRange = ({
|
|||
},
|
||||
size: 100,
|
||||
track_total_hits: true,
|
||||
},
|
||||
ignore_unavailable: true,
|
||||
index: indexName,
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
SearchRequest,
|
||||
SearchTotalHits,
|
||||
AggregationsAggregationContainer,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { BoolQuery } from '@kbn/es-query';
|
||||
import {
|
||||
ALERT_END,
|
||||
|
@ -53,7 +53,7 @@ const getLifecycleAlertsQueryByExecutionUuid = ({
|
|||
ruleId,
|
||||
excludedAlertInstanceIds,
|
||||
alertsFilter,
|
||||
}: GetLifecycleAlertsQueryByExecutionUuidParams): SearchRequest[] => {
|
||||
}: GetLifecycleAlertsQueryByExecutionUuidParams): Array<SearchRequest['body']> => {
|
||||
// lifecycle alerts assign a different action to an alert depending
|
||||
// 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
|
||||
|
@ -89,7 +89,7 @@ const getLifecycleAlertsQueryByTimeRange = ({
|
|||
ruleId,
|
||||
excludedAlertInstanceIds,
|
||||
alertsFilter,
|
||||
}: GetLifecycleAlertsQueryByTimeRangeParams): SearchRequest[] => {
|
||||
}: GetLifecycleAlertsQueryByTimeRangeParams): Array<SearchRequest['body']> => {
|
||||
return [
|
||||
getQueryByTimeRange({
|
||||
start,
|
||||
|
@ -124,7 +124,7 @@ const getQueryByExecutionUuid = ({
|
|||
excludedAlertInstanceIds,
|
||||
action,
|
||||
alertsFilter,
|
||||
}: GetQueryByExecutionUuidParams): SearchRequest => {
|
||||
}: GetQueryByExecutionUuidParams): SearchRequest['body'] => {
|
||||
const filter: QueryDslQueryContainer[] = [
|
||||
{
|
||||
term: {
|
||||
|
@ -187,7 +187,7 @@ const getQueryByTimeRange = ({
|
|||
excludedAlertInstanceIds,
|
||||
type,
|
||||
alertsFilter,
|
||||
}: GetQueryByTimeRangeParams<AlertTypes>): SearchRequest => {
|
||||
}: GetQueryByTimeRangeParams<AlertTypes>): SearchRequest['body'] => {
|
||||
// base query filters the alert documents for a rule by the given time range
|
||||
let filter: QueryDslQueryContainer[] = [
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ export const getQueryByScopedQueries = ({
|
|||
ruleId,
|
||||
action,
|
||||
maintenanceWindows,
|
||||
}: GetQueryByScopedQueriesParams): SearchRequest => {
|
||||
}: GetQueryByScopedQueriesParams): SearchRequest['body'] => {
|
||||
const filters: QueryDslQueryContainer[] = [
|
||||
{
|
||||
term: {
|
||||
|
@ -460,7 +460,7 @@ const getLifecycleAlertsQueries = ({
|
|||
ruleId,
|
||||
excludedAlertInstanceIds,
|
||||
alertsFilter,
|
||||
}: GetAlertsQueryParams): SearchRequest[] => {
|
||||
}: GetAlertsQueryParams): Array<SearchRequest['body']> => {
|
||||
let queryBodies;
|
||||
if (!!executionUuid) {
|
||||
queryBodies = getLifecycleAlertsQueryByExecutionUuid({
|
||||
|
@ -489,7 +489,7 @@ const getContinualAlertsQuery = ({
|
|||
ruleId,
|
||||
excludedAlertInstanceIds,
|
||||
alertsFilter,
|
||||
}: GetAlertsQueryParams): SearchRequest => {
|
||||
}: GetAlertsQueryParams): SearchRequest['body'] => {
|
||||
let queryBody;
|
||||
if (!!executionUuid) {
|
||||
queryBody = getQueryByExecutionUuid({
|
||||
|
@ -516,7 +516,7 @@ const getMaintenanceWindowAlertsQuery = ({
|
|||
ruleId,
|
||||
action,
|
||||
maintenanceWindows,
|
||||
}: GetMaintenanceWindowAlertsQueryParams): SearchRequest => {
|
||||
}: GetMaintenanceWindowAlertsQueryParams): SearchRequest['body'] => {
|
||||
return getQueryByScopedQueries({
|
||||
executionUuid,
|
||||
ruleId,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
export const injectAnalyzeWildcard = (query: QueryDslQueryContainer): void => {
|
||||
if (!query) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
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';
|
||||
|
||||
// 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 { get } from 'lodash';
|
||||
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 = (
|
||||
response: TransportResult<estypes.BulkResponse, unknown> | estypes.BulkResponse
|
||||
|
|
|
@ -10,7 +10,7 @@ import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-m
|
|||
import {
|
||||
IndicesGetDataStreamResponse,
|
||||
IndicesDataStreamIndex,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { errors as EsErrors } from '@elastic/elasticsearch';
|
||||
import { ReplaySubject, Subject, of } from 'rxjs';
|
||||
import { AlertsService } from './alerts_service';
|
||||
|
@ -150,6 +150,7 @@ const getIndexTemplatePutBody = (opts?: GetIndexTemplatePutBodyOpts) => {
|
|||
];
|
||||
return {
|
||||
name: `.alerts-${context ? context : 'test'}.alerts-${namespace}-index-template`,
|
||||
body: {
|
||||
index_patterns: indexPatterns,
|
||||
composed_of: [
|
||||
...(useEcs ? ['.alerts-ecs-mappings'] : []),
|
||||
|
@ -197,6 +198,7 @@ const getIndexTemplatePutBody = (opts?: GetIndexTemplatePutBodyOpts) => {
|
|||
managed: true,
|
||||
namespace,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -471,6 +473,7 @@ describe('Alerts Service', () => {
|
|||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
||||
name: existingIndexTemplate.name,
|
||||
body: {
|
||||
...existingIndexTemplate.index_template,
|
||||
template: {
|
||||
...existingIndexTemplate.index_template.template,
|
||||
|
@ -479,6 +482,7 @@ describe('Alerts Service', () => {
|
|||
'index.mapping.total_fields.limit': 2500,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(clusterClient.ilm.putLifecycle).toHaveBeenCalledTimes(
|
||||
|
@ -554,11 +558,13 @@ describe('Alerts Service', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(clusterClient.indices.getAlias).toHaveBeenCalledWith({
|
||||
index: [
|
||||
|
@ -618,11 +624,13 @@ describe('Alerts Service', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(clusterClient.indices.getAlias).toHaveBeenCalledWith({
|
||||
index: [
|
||||
|
@ -678,11 +686,13 @@ describe('Alerts Service', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(clusterClient.indices.getAlias).toHaveBeenCalledWith({
|
||||
index: [
|
||||
|
@ -721,11 +731,13 @@ describe('Alerts Service', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenNthCalledWith(1, {
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(clusterClient.indices.getAlias).toHaveBeenNthCalledWith(1, {
|
||||
index: [
|
||||
|
@ -786,11 +798,13 @@ describe('Alerts Service', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenNthCalledWith(2, {
|
||||
index: '.internal.alerts-test.alerts-another-namespace-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-another-namespace': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(clusterClient.indices.getAlias).toHaveBeenNthCalledWith(2, {
|
||||
index: [
|
||||
|
@ -841,11 +855,13 @@ describe('Alerts Service', () => {
|
|||
expect(clusterClient.indices.putMapping).toHaveBeenCalledTimes(2);
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -875,6 +891,7 @@ describe('Alerts Service', () => {
|
|||
|
||||
const template = {
|
||||
name: `.alerts-empty.alerts-default-index-template`,
|
||||
body: {
|
||||
index_patterns: useDataStreamForAlerts
|
||||
? [`.alerts-empty.alerts-default`]
|
||||
: [
|
||||
|
@ -913,6 +930,7 @@ describe('Alerts Service', () => {
|
|||
managed: true,
|
||||
namespace: 'default',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith(template);
|
||||
|
@ -926,11 +944,13 @@ describe('Alerts Service', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-empty.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-empty.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(clusterClient.indices.getAlias).toHaveBeenCalledWith({
|
||||
index: [
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IlmPolicy } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { IlmPolicy } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
/**
|
||||
* Default alert index ILM policy
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
|
||||
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 { getDataStreamAdapter } from './data_stream_adapter';
|
||||
|
||||
|
@ -95,11 +95,13 @@ describe('createConcreteWriteIndex', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -307,11 +309,13 @@ describe('createConcreteWriteIndex', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -355,11 +359,13 @@ describe('createConcreteWriteIndex', () => {
|
|||
if (!useDataStream) {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -393,11 +399,13 @@ describe('createConcreteWriteIndex', () => {
|
|||
if (!useDataStream) {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
`Found unexpected concrete index name "bad_index_name" while expecting index with one of the following prefixes: [.internal.alerts-,.alerts-] Not updating mappings or settings for this index.`
|
||||
|
@ -623,11 +631,13 @@ describe('createConcreteWriteIndex', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -660,11 +670,13 @@ describe('createConcreteWriteIndex', () => {
|
|||
} else {
|
||||
expect(clusterClient.indices.create).toHaveBeenCalledWith({
|
||||
index: '.internal.alerts-test.alerts-default-000001',
|
||||
body: {
|
||||
aliases: {
|
||||
'.alerts-test.alerts-default': {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -744,6 +756,7 @@ describe('setConcreteWriteIndex', () => {
|
|||
'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({
|
||||
body: {
|
||||
actions: [
|
||||
{
|
||||
remove: {
|
||||
|
@ -759,6 +772,7 @@ describe('setConcreteWriteIndex', () => {
|
|||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(logger.info).toHaveBeenCalledWith(
|
||||
'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.
|
||||
*/
|
||||
|
||||
import { IndicesSimulateIndexTemplateResponse } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { IndicesSimulateIndexTemplateResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||
import { get, sortBy } from 'lodash';
|
||||
import { IIndexPatternString } from '../resource_installer_utils';
|
||||
|
@ -45,7 +45,7 @@ const updateTotalFieldLimitSetting = async ({
|
|||
() =>
|
||||
esClient.indices.putSettings({
|
||||
index,
|
||||
settings: { 'index.mapping.total_fields.limit': totalFieldsLimit },
|
||||
body: { 'index.mapping.total_fields.limit': totalFieldsLimit },
|
||||
}),
|
||||
{ logger }
|
||||
);
|
||||
|
@ -90,7 +90,7 @@ const updateUnderlyingMapping = async ({
|
|||
|
||||
try {
|
||||
await retryTransientEsErrors(
|
||||
() => esClient.indices.putMapping({ index, ...simulatedMapping }),
|
||||
() => esClient.indices.putMapping({ index, body: simulatedMapping }),
|
||||
{ logger }
|
||||
);
|
||||
|
||||
|
@ -183,6 +183,7 @@ export async function setConcreteWriteIndex(opts: SetConcreteWriteIndexOpts) {
|
|||
await retryTransientEsErrors(
|
||||
() =>
|
||||
esClient.indices.updateAliases({
|
||||
body: {
|
||||
actions: [
|
||||
{ remove: { index: concreteIndex.index, alias: concreteIndex.alias } },
|
||||
{
|
||||
|
@ -193,6 +194,7 @@ export async function setConcreteWriteIndex(opts: SetConcreteWriteIndexOpts) {
|
|||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
{ logger }
|
||||
);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks';
|
||||
import { ClusterPutComponentTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { errors as EsErrors } from '@elastic/elasticsearch';
|
||||
import { createOrUpdateComponentTemplate } from './create_or_update_component_template';
|
||||
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
|
||||
|
@ -14,7 +13,7 @@ const randomDelayMultiplier = 0.01;
|
|||
const logger = loggingSystemMock.createLogger();
|
||||
const clusterClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
|
||||
|
||||
const ComponentTemplate: ClusterPutComponentTemplateRequest = {
|
||||
const ComponentTemplate = {
|
||||
name: 'test-mappings',
|
||||
_meta: {
|
||||
managed: true,
|
||||
|
@ -177,6 +176,7 @@ describe('createOrUpdateComponentTemplate', () => {
|
|||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
||||
name: existingIndexTemplate.name,
|
||||
body: {
|
||||
...existingIndexTemplate.index_template,
|
||||
template: {
|
||||
...existingIndexTemplate.index_template.template,
|
||||
|
@ -185,6 +185,7 @@ describe('createOrUpdateComponentTemplate', () => {
|
|||
'index.mapping.total_fields.limit': 2500,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -281,6 +282,7 @@ describe('createOrUpdateComponentTemplate', () => {
|
|||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
|
||||
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
|
||||
name: existingIndexTemplate.name,
|
||||
body: {
|
||||
...existingIndexTemplate.index_template,
|
||||
template: {
|
||||
...existingIndexTemplate.index_template.template,
|
||||
|
@ -289,6 +291,7 @@ describe('createOrUpdateComponentTemplate', () => {
|
|||
'index.mapping.total_fields.limit': 2500,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import {
|
||||
ClusterPutComponentTemplateRequest,
|
||||
IndicesGetIndexTemplateIndexTemplateItem,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||
import { asyncForEach } from '@kbn/std';
|
||||
import { retryTransientEsErrors } from './retry_transient_es_errors';
|
||||
|
@ -50,6 +50,7 @@ const getIndexTemplatesUsingComponentTemplate = async (
|
|||
() =>
|
||||
esClient.indices.putIndexTemplate({
|
||||
name: template.name,
|
||||
body: {
|
||||
...template.index_template,
|
||||
template: {
|
||||
...template.index_template.template,
|
||||
|
@ -58,6 +59,7 @@ const getIndexTemplatesUsingComponentTemplate = async (
|
|||
'index.mapping.total_fields.limit': totalFieldsLimit,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ logger }
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 { retryTransientEsErrors } from './retry_transient_es_errors';
|
||||
import { DataStreamAdapter } from './data_stream_adapter';
|
||||
|
|
|
@ -16,6 +16,7 @@ const clusterClient = elasticsearchServiceMock.createClusterClient().asInternalU
|
|||
|
||||
const IndexTemplate = (namespace: string = 'default', useDataStream: boolean = false) => ({
|
||||
name: `.alerts-test.alerts-${namespace}-index-template`,
|
||||
body: {
|
||||
_meta: {
|
||||
kibana: {
|
||||
version: '8.6.1',
|
||||
|
@ -52,6 +53,7 @@ const IndexTemplate = (namespace: string = 'default', useDataStream: boolean = f
|
|||
},
|
||||
},
|
||||
priority: namespace.length,
|
||||
},
|
||||
});
|
||||
|
||||
const SimulateTemplateResponse = {
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
IndicesPutIndexTemplateRequest,
|
||||
MappingTypeMapping,
|
||||
Metadata,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { IIndexPatternString } from '../resource_installer_utils';
|
||||
|
@ -57,6 +57,7 @@ export const getIndexTemplate = ({
|
|||
|
||||
return {
|
||||
name: indexPatterns.template,
|
||||
body: {
|
||||
...(dataStreamFields.data_stream ? { data_stream: dataStreamFields.data_stream } : {}),
|
||||
index_patterns: dataStreamFields.index_patterns,
|
||||
composed_of: componentTemplateRefs,
|
||||
|
@ -91,6 +92,7 @@ export const getIndexTemplate = ({
|
|||
// 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
|
||||
priority: namespace.length,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -208,11 +208,13 @@ async function createAliasStream(opts: CreateConcreteWriteIndexOpts): Promise<vo
|
|||
() =>
|
||||
esClient.indices.create({
|
||||
index: indexPatterns.name,
|
||||
body: {
|
||||
aliases: {
|
||||
[indexPatterns.alias]: {
|
||||
is_write_index: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ logger }
|
||||
);
|
||||
|
|
|
@ -59,10 +59,8 @@ describe('setAlertsToUntracked()', () => {
|
|||
Array [
|
||||
Object {
|
||||
"allow_no_indices": true,
|
||||
"body": Object {
|
||||
"conflicts": "proceed",
|
||||
"index": Array [
|
||||
"test-index",
|
||||
],
|
||||
"query": Object {
|
||||
"bool": Object {
|
||||
"must": Array [
|
||||
|
@ -94,7 +92,6 @@ describe('setAlertsToUntracked()', () => {
|
|||
],
|
||||
},
|
||||
},
|
||||
"refresh": true,
|
||||
"script": Object {
|
||||
"lang": "painless",
|
||||
"source": "
|
||||
|
@ -109,6 +106,11 @@ describe('setAlertsToUntracked()', () => {
|
|||
}",
|
||||
},
|
||||
},
|
||||
"index": Array [
|
||||
"test-index",
|
||||
],
|
||||
"refresh": true,
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
@ -126,10 +128,8 @@ describe('setAlertsToUntracked()', () => {
|
|||
Array [
|
||||
Object {
|
||||
"allow_no_indices": true,
|
||||
"body": Object {
|
||||
"conflicts": "proceed",
|
||||
"index": Array [
|
||||
"test-index",
|
||||
],
|
||||
"query": Object {
|
||||
"bool": Object {
|
||||
"must": Array [
|
||||
|
@ -161,7 +161,6 @@ describe('setAlertsToUntracked()', () => {
|
|||
],
|
||||
},
|
||||
},
|
||||
"refresh": true,
|
||||
"script": Object {
|
||||
"lang": "painless",
|
||||
"source": "
|
||||
|
@ -176,6 +175,11 @@ describe('setAlertsToUntracked()', () => {
|
|||
}",
|
||||
},
|
||||
},
|
||||
"index": Array [
|
||||
"test-index",
|
||||
],
|
||||
"refresh": true,
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
@ -453,6 +457,7 @@ describe('setAlertsToUntracked()', () => {
|
|||
|
||||
expect(clusterClient.updateByQuery).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
|
@ -477,11 +482,13 @@ describe('setAlertsToUntracked()', () => {
|
|||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
expect(clusterClient.search).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
|
@ -506,6 +513,7 @@ describe('setAlertsToUntracked()', () => {
|
|||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -588,6 +596,7 @@ describe('setAlertsToUntracked()', () => {
|
|||
|
||||
expect(clusterClient.updateByQuery).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
|
@ -612,6 +621,7 @@ describe('setAlertsToUntracked()', () => {
|
|||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
ALERT_UUID,
|
||||
AlertStatus,
|
||||
} 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 { AlertingAuthorizationEntity } from '../../authorization/types';
|
||||
|
||||
|
@ -125,6 +125,7 @@ const ensureAuthorizedToUntrack = async (params: SetAlertsToUntrackedParamsWithD
|
|||
const response = await esClient.search<never, ConsumersAndRuleTypesAggregation>({
|
||||
index: indices,
|
||||
allow_no_indices: true,
|
||||
body: {
|
||||
size: 0,
|
||||
query: getUntrackQuery(params, ALERT_STATUS_ACTIVE),
|
||||
aggs: {
|
||||
|
@ -133,6 +134,7 @@ const ensureAuthorizedToUntrack = async (params: SetAlertsToUntrackedParamsWithD
|
|||
aggs: { consumers: { terms: { field: ALERT_RULE_CONSUMER } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const ruleTypeIdBuckets = response.aggregations?.ruleTypeIds.buckets;
|
||||
if (!ruleTypeIdBuckets) {
|
||||
|
@ -216,12 +218,14 @@ export async function setAlertsToUntracked(
|
|||
const response = await esClient.updateByQuery({
|
||||
index: indices,
|
||||
allow_no_indices: true,
|
||||
body: {
|
||||
conflicts: 'proceed',
|
||||
script: {
|
||||
source: getUntrackUpdatePainlessScript(new Date()),
|
||||
lang: 'painless',
|
||||
},
|
||||
query: getUntrackQuery(params, ALERT_STATUS_ACTIVE),
|
||||
},
|
||||
refresh: true,
|
||||
});
|
||||
|
||||
|
@ -255,9 +259,11 @@ export async function setAlertsToUntracked(
|
|||
const searchResponse = await esClient.search({
|
||||
index: indices,
|
||||
allow_no_indices: true,
|
||||
body: {
|
||||
_source: [ALERT_RULE_UUID, ALERT_UUID],
|
||||
size: total,
|
||||
query: getUntrackQuery(params, ALERT_STATUS_UNTRACKED),
|
||||
},
|
||||
});
|
||||
|
||||
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.
|
||||
*/
|
||||
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 { KueryNode } from '@kbn/es-query';
|
||||
import { aggregateOptionsSchema } from '../schemas';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 = [
|
||||
'alert.attributes.executionStatus.status',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { remove } from 'lodash';
|
||||
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';
|
||||
|
||||
export enum AlertingAuthorizationFilterType {
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
import {
|
||||
AggregationsStringTermsBucketKeys,
|
||||
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 { InvalidateAPIKeyResult } from '../rules_client';
|
||||
import { AlertingConfig } from '../config';
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
* 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) => {
|
||||
if (typeof sort === 'string') {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
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 { flatMap, get, isEmpty } from 'lodash';
|
||||
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';
|
||||
|
||||
const esQuery = {
|
||||
query: { bool: { filter: { range: { '@timestamp': { gte: 0 } } } } },
|
||||
body: { query: { bool: { filter: { range: { '@timestamp': { gte: 0 } } } } } },
|
||||
};
|
||||
const eqlQuery = {
|
||||
index: 'foo',
|
||||
|
@ -20,7 +20,9 @@ const eqlQuery = {
|
|||
const esqlQueryRequest = {
|
||||
method: 'POST',
|
||||
path: '/_query',
|
||||
body: {
|
||||
query: 'from .kibana_task_manager',
|
||||
},
|
||||
};
|
||||
|
||||
let logger = loggingSystemMock.create().get();
|
||||
|
@ -71,7 +73,7 @@ describe('wrapScopedClusterClient', () => {
|
|||
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||
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(
|
||||
`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.asCurrentUser.search).not.toHaveBeenCalled();
|
||||
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(
|
||||
`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(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(
|
||||
`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!"`);
|
||||
|
||||
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.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(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(
|
||||
`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(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(
|
||||
`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(
|
||||
`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.warn).not.toHaveBeenCalled();
|
||||
|
@ -457,7 +459,7 @@ describe('wrapScopedClusterClient', () => {
|
|||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||
|
||||
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();
|
||||
});
|
||||
|
@ -483,7 +485,7 @@ describe('wrapScopedClusterClient', () => {
|
|||
expect(scopedClusterClient.asInternalUser.search).not.toHaveBeenCalled();
|
||||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||
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();
|
||||
});
|
||||
|
@ -514,7 +516,7 @@ describe('wrapScopedClusterClient', () => {
|
|||
expect(scopedClusterClient.asCurrentUser.search).not.toHaveBeenCalled();
|
||||
|
||||
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();
|
||||
});
|
||||
|
@ -570,7 +572,7 @@ describe('wrapScopedClusterClient', () => {
|
|||
expect(stats.totalSearchDurationMs).toBeGreaterThan(-1);
|
||||
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ import type {
|
|||
SearchRequest as SearchRequestWithBody,
|
||||
AggregationsAggregate,
|
||||
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 { SearchMetrics, RuleInfo } from './types';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import type {
|
||||
AggregationsKeyedPercentiles,
|
||||
AggregationsPercentilesAggregateBase,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
|
||||
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/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 type { ConfigSchema } from '@kbn/unified-search-plugin/server/config';
|
||||
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 { 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 { 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 type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
import { verifyAccessAndContext } from '../lib';
|
||||
import { ILicenseState } from '../../lib';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { convertEsSortToEventLogSort } from '../../lib';
|
||||
import {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 { SanitizedRuleWithLegacyId } from '../../types';
|
||||
import {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 {
|
||||
savedObjectsClientMock,
|
||||
|
|
|
@ -477,7 +477,7 @@ describe('Ad Hoc Task Runner', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: {
|
||||
_id: UUID,
|
||||
|
@ -745,13 +745,13 @@ describe('Ad Hoc Task Runner', () => {
|
|||
const bulkCall = clusterClient.bulk.mock.calls[0][0];
|
||||
|
||||
// @ts-ignore
|
||||
expect(bulkCall.operations[1][TIMESTAMP]).toEqual(schedule4.runAt);
|
||||
expect(bulkCall.body[1][TIMESTAMP]).toEqual(schedule4.runAt);
|
||||
// @ts-ignore
|
||||
expect(bulkCall.operations[1][ALERT_START]).toEqual(schedule4.runAt);
|
||||
expect(bulkCall.body[1][ALERT_START]).toEqual(schedule4.runAt);
|
||||
// @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
|
||||
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(
|
||||
AD_HOC_RUN_SAVED_OBJECT_TYPE,
|
||||
|
@ -852,13 +852,13 @@ describe('Ad Hoc Task Runner', () => {
|
|||
const bulkCall = clusterClient.bulk.mock.calls[0][0];
|
||||
|
||||
// @ts-ignore
|
||||
expect(bulkCall.operations[1][TIMESTAMP]).toEqual(schedule5.runAt);
|
||||
expect(bulkCall.body[1][TIMESTAMP]).toEqual(schedule5.runAt);
|
||||
// @ts-ignore
|
||||
expect(bulkCall.operations[1][ALERT_START]).toEqual(schedule5.runAt);
|
||||
expect(bulkCall.body[1][ALERT_START]).toEqual(schedule5.runAt);
|
||||
// @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
|
||||
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(
|
||||
AD_HOC_RUN_SAVED_OBJECT_TYPE,
|
||||
|
|
|
@ -593,7 +593,7 @@ describe('Task Runner', () => {
|
|||
index: '.alerts-test.alerts-default',
|
||||
refresh: 'wait_for',
|
||||
require_alias: !useDataStreamForAlerts,
|
||||
operations: [
|
||||
body: [
|
||||
{
|
||||
create: {
|
||||
_id: '5f6aa57d-3e22-484e-bae8-cbed868f4d28',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import type {
|
||||
AggregationsTermsAggregateBase,
|
||||
AggregationsStringTermsBucketKeys,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||
|
||||
import { NUM_ALERTING_RULE_TYPES } from '../alerting_usage_collector';
|
||||
|
@ -38,6 +38,7 @@ export async function getTotalAlertsCountAggregations({
|
|||
const query = {
|
||||
index: AAD_INDEX_PATTERN,
|
||||
size: 0,
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
|
@ -49,6 +50,7 @@ export async function getTotalAlertsCountAggregations({
|
|||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
logger.debug(() => `query for getTotalAlertsCountAggregations - ${JSON.stringify(query)}`);
|
||||
|
|
|
@ -14,7 +14,7 @@ import type {
|
|||
AggregationsTermsAggregateBase,
|
||||
AggregationsStringTermsBucketKeys,
|
||||
AggregationsBuckets,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||
import {
|
||||
NUM_ALERTING_RULE_TYPES,
|
||||
|
@ -136,6 +136,7 @@ export async function getExecutionsPerDayCount({
|
|||
const query = {
|
||||
index: eventLogIndex,
|
||||
size: 0,
|
||||
body: {
|
||||
query: getProviderAndActionFilterForTimeRange('execute'),
|
||||
aggs: {
|
||||
...eventLogAggs,
|
||||
|
@ -152,6 +153,7 @@ export async function getExecutionsPerDayCount({
|
|||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
logger.debug(() => `query for getExecutionsPerDayCount - ${JSON.stringify(query)}`);
|
||||
|
@ -227,6 +229,7 @@ export async function getExecutionTimeoutsPerDayCount({
|
|||
const query = {
|
||||
index: eventLogIndex,
|
||||
size: 0,
|
||||
body: {
|
||||
query: getProviderAndActionFilterForTimeRange('execute-timeout'),
|
||||
aggs: {
|
||||
by_rule_type_id: {
|
||||
|
@ -236,6 +239,7 @@ export async function getExecutionTimeoutsPerDayCount({
|
|||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
logger.debug(() => `query for getExecutionTimeoutsPerDayCount - ${JSON.stringify(query)}`);
|
||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
|||
AggregationsCardinalityAggregate,
|
||||
AggregationsTermsAggregateBase,
|
||||
AggregationsStringTermsBucketKeys,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { ElasticsearchClient, Logger, ISavedObjectsRepository } from '@kbn/core/server';
|
||||
|
||||
import {
|
||||
|
@ -83,6 +83,7 @@ export async function getTotalCountAggregations({
|
|||
const query = {
|
||||
index: alertIndex,
|
||||
size: 0,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
// Aggregate over all rule saved objects
|
||||
|
@ -286,6 +287,7 @@ export async function getTotalCountAggregations({
|
|||
sum_rules_muted: { sum: { field: 'rule_muted' } },
|
||||
sum_rules_with_muted_alerts: { sum: { field: 'rule_with_muted_alerts' } },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
logger.debug(() => `query for getTotalCountAggregations - ${JSON.stringify(query)}`);
|
||||
|
@ -437,6 +439,7 @@ export async function getTotalCountInUse({
|
|||
const query = {
|
||||
index: alertIndex,
|
||||
size: 0,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
// Aggregate over only enabled rule saved objects
|
||||
|
@ -457,6 +460,7 @@ export async function getTotalCountInUse({
|
|||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
logger.debug(() => `query for getTotalCountInUse - ${JSON.stringify(query)}`);
|
||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
|||
AggregationsTermsAggregateBase,
|
||||
AggregationsStringTermsBucketKeys,
|
||||
AggregationsBuckets,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { ElasticsearchClient, Logger } from '@kbn/core/server';
|
||||
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
||||
import { NUM_ALERTING_RULE_TYPES } from '../alerting_usage_collector';
|
||||
|
@ -42,6 +42,7 @@ export async function getFailedAndUnrecognizedTasksPerDay({
|
|||
const query = {
|
||||
index: taskManagerIndex,
|
||||
size: 0,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
must: [
|
||||
|
@ -95,6 +96,7 @@ export async function getFailedAndUnrecognizedTasksPerDay({
|
|||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
logger.debug(() => `query for getFailedAndUnrecognizedTasksPerDay - ${JSON.stringify(query)}`);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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';
|
||||
|
||||
export interface ConnectorsByConsumersBucket {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import {
|
||||
AggregationsBuckets,
|
||||
AggregationsStringTermsBucketKeys,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { replaceDotSymbols } from './replace_dots_with_underscores';
|
||||
|
||||
export function parseSimpleRuleTypeBucket(
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
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 { AggregationBuilder, AggregationResponse } from '../../types';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type {
|
||||
CasesMetricsFeatureField,
|
||||
SingleCaseMetricsFeatureField,
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
SavedObjectsUpdateResponse,
|
||||
} 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 { AttachmentAttributesRt, AttachmentType } from '../../../common/types/domain';
|
||||
import { decodeOrThrow } from '../../common/runtime_types';
|
||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
|||
SavedObjectsBulkResponse,
|
||||
SavedObjectsFindResponse,
|
||||
} 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 { isSOError } from '../../../common/error';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type {
|
||||
Logger,
|
||||
SavedObject,
|
||||
|
|
|
@ -18,7 +18,7 @@ import type {
|
|||
SavedObjectsBulkDeleteOptions,
|
||||
} 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 type { Case, CaseStatuses, User } from '../../../common/types/domain';
|
||||
|
|
|
@ -11,7 +11,7 @@ import type {
|
|||
SavedObjectsRawDoc,
|
||||
} 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 { CaseUserActionDeprecatedResponse } from '../../../common/types/api';
|
||||
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 { Logger, ElasticsearchClient } from '@kbn/core/server';
|
||||
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 { IEvent, IValidatedEvent, SAVED_OBJECT_REL_PRIMARY } from '../types';
|
||||
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'])
|
||||
);
|
||||
|
||||
const body: estypes.SearchRequest = {
|
||||
const body: estypes.SearchRequest['body'] = {
|
||||
size: perPage,
|
||||
from: (page - 1) * perPage,
|
||||
query,
|
||||
|
@ -443,7 +443,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
|||
pick(queryOptions.findOptions, ['start', 'end', 'filter'])
|
||||
);
|
||||
|
||||
const body: estypes.SearchRequest = {
|
||||
const body: estypes.SearchRequest['body'] = {
|
||||
size: perPage,
|
||||
from: (page - 1) * perPage,
|
||||
query,
|
||||
|
@ -487,7 +487,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
|||
pick(queryOptions.aggregateOptions, ['start', 'end', 'filter'])
|
||||
);
|
||||
|
||||
const body: estypes.SearchRequest = {
|
||||
const body: estypes.SearchRequest['body'] = {
|
||||
size: 0,
|
||||
query,
|
||||
aggs,
|
||||
|
@ -523,7 +523,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
|||
pick(queryOptions.aggregateOptions, ['start', 'end', 'filter'])
|
||||
);
|
||||
|
||||
const body: estypes.SearchRequest = {
|
||||
const body: estypes.SearchRequest['body'] = {
|
||||
size: 0,
|
||||
query,
|
||||
aggs,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 { groupBy } from 'lodash';
|
||||
import pRetry, { FailedAttemptError } from 'p-retry';
|
||||
|
|
|
@ -9,7 +9,7 @@ import { omit } from 'lodash';
|
|||
import { Observable } from 'rxjs';
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
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 { KueryNode } from '@kbn/es-query';
|
||||
|
|
|
@ -93,8 +93,8 @@ export class ResourceInstaller {
|
|||
logger,
|
||||
esClient: clusterClient,
|
||||
template: {
|
||||
...ecsComponentTemplate,
|
||||
name: ECS_COMPONENT_TEMPLATE_NAME,
|
||||
body: ecsComponentTemplate,
|
||||
},
|
||||
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
||||
}),
|
||||
|
@ -103,8 +103,8 @@ export class ResourceInstaller {
|
|||
logger,
|
||||
esClient: clusterClient,
|
||||
template: {
|
||||
...technicalComponentTemplate,
|
||||
name: TECHNICAL_COMPONENT_TEMPLATE_NAME,
|
||||
body: technicalComponentTemplate,
|
||||
},
|
||||
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
|
||||
}),
|
||||
|
@ -168,12 +168,14 @@ export class ResourceInstaller {
|
|||
esClient: clusterClient,
|
||||
template: {
|
||||
name: indexInfo.getComponentTemplateName(ct.name),
|
||||
body: {
|
||||
template: {
|
||||
settings: ct.settings ?? {},
|
||||
mappings: ct.mappings,
|
||||
},
|
||||
_meta: ct._meta,
|
||||
},
|
||||
},
|
||||
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.
|
||||
*/
|
||||
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';
|
||||
|
||||
interface BuildSortedEventsQueryOpts {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { EsQueryRuleParams } from './rule_type_params';
|
||||
import { Comparator } from '../../../common/comparator_types';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { EsQueryRuleParams } from './rule_type_params';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 { ConnectorUsageCollector } from '@kbn/actions-plugin/server/types';
|
||||
import { actionsMock } from '@kbn/actions-plugin/server/mocks';
|
||||
|
@ -205,8 +205,7 @@ describe('execute()', () => {
|
|||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"index": "index-value",
|
||||
"operations": Array [
|
||||
"body": Array [
|
||||
Object {
|
||||
"index": Object {
|
||||
"op_type": "create",
|
||||
|
@ -216,6 +215,7 @@ describe('execute()', () => {
|
|||
"jim": "bob",
|
||||
},
|
||||
],
|
||||
"index": "index-value",
|
||||
"refresh": false,
|
||||
},
|
||||
],
|
||||
|
@ -247,17 +247,16 @@ describe('execute()', () => {
|
|||
|
||||
const calls = scopedClusterClient.bulk.mock.calls;
|
||||
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;
|
||||
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;
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"index": "index-value",
|
||||
"operations": Array [
|
||||
"body": Array [
|
||||
Object {
|
||||
"index": Object {
|
||||
"op_type": "create",
|
||||
|
@ -267,6 +266,7 @@ describe('execute()', () => {
|
|||
"jimbob": "jr",
|
||||
},
|
||||
],
|
||||
"index": "index-value",
|
||||
"refresh": true,
|
||||
},
|
||||
],
|
||||
|
@ -301,8 +301,7 @@ describe('execute()', () => {
|
|||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"index": "index-value",
|
||||
"operations": Array [
|
||||
"body": Array [
|
||||
Object {
|
||||
"index": Object {
|
||||
"op_type": "create",
|
||||
|
@ -312,6 +311,7 @@ describe('execute()', () => {
|
|||
"jim": "bob",
|
||||
},
|
||||
],
|
||||
"index": "index-value",
|
||||
"refresh": false,
|
||||
},
|
||||
],
|
||||
|
@ -345,8 +345,7 @@ describe('execute()', () => {
|
|||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"index": "index-value",
|
||||
"operations": Array [
|
||||
"body": Array [
|
||||
Object {
|
||||
"index": Object {
|
||||
"op_type": "create",
|
||||
|
@ -364,6 +363,7 @@ describe('execute()', () => {
|
|||
"b": 2,
|
||||
},
|
||||
],
|
||||
"index": "index-value",
|
||||
"refresh": false,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -25,7 +25,10 @@ import {
|
|||
ALERT_HISTORY_PREFIX,
|
||||
buildAlertHistoryDocument,
|
||||
} 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<
|
||||
ConnectorTypeConfigType,
|
||||
|
@ -105,20 +108,20 @@ async function executor(
|
|||
const { actionId, config, params, services, logger } = execOptions;
|
||||
const index = params.indexOverride || config.index;
|
||||
|
||||
const operations = [];
|
||||
const bulkBody = [];
|
||||
for (const document of params.documents) {
|
||||
const timeField = config.executionTimeField == null ? '' : config.executionTimeField.trim();
|
||||
if (timeField !== '') {
|
||||
document[timeField] = new Date();
|
||||
}
|
||||
|
||||
operations.push({ index: { op_type: 'create' } });
|
||||
operations.push(document);
|
||||
bulkBody.push({ index: { op_type: 'create' } });
|
||||
bulkBody.push(document);
|
||||
}
|
||||
|
||||
const bulkParams = {
|
||||
index,
|
||||
operations,
|
||||
body: bulkBody,
|
||||
refresh: config.refresh,
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { Logger } from '@kbn/core/server';
|
||||
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 { bufferWhen, filter, bufferCount, flatMap, mapTo, first } from 'rxjs';
|
||||
import { SavedObjectError } from '@kbn/core-saved-objects-common';
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
AggregationsStringTermsBucket,
|
||||
AggregationsStringTermsBucketKeys,
|
||||
AggregationsTermsAggregateBase,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { TaskStore } from '../task_store';
|
||||
import {
|
||||
|
|
|
@ -21,7 +21,7 @@ import { times } from 'lodash';
|
|||
import { taskStoreMock } from '../task_store.mock';
|
||||
import { of, Subject } from 'rxjs';
|
||||
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';
|
||||
|
||||
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 { JsonObject } from '@kbn/utility-types';
|
||||
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 { AggregatedStatProvider } from '../lib/runtime_statistics_aggregator';
|
||||
import { parseIntervalAsSecond, asInterval, parseIntervalAsMillisecond } from '../lib/intervals';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { combineLatest, Observable, Subject, BehaviorSubject } 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 {
|
||||
UsageCollectionSetup,
|
||||
UsageCollectionStart,
|
||||
|
|
|
@ -9,7 +9,7 @@ import type {
|
|||
AggregationsAggregationContainer,
|
||||
QueryDslQueryContainer,
|
||||
MappingRuntimeFields,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import {
|
||||
IdleTaskWithExpiredRunAt,
|
||||
RunningOrClaimingTaskWithExpiredRetryAt,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 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 { TaskStatus, TaskPriority, ConcreteTaskInstance } from '../task';
|
||||
import {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 {
|
||||
bool: Pick<estypes.QueryDslBoolQuery, 'must'>;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { mockLogger } from '../test_utils';
|
||||
import { coreMock, elasticsearchServiceMock } from '@kbn/core/server/mocks';
|
||||
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> => ({
|
||||
_index: '.kibana_task_manager_9.0.0_001',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { Logger } from '@kbn/logging';
|
||||
import { CoreStart } from '@kbn/core-lifecycle-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 { TaskTypeDictionary } from '../task_type_dictionary';
|
||||
import { ConcreteTaskInstance, TaskManagerStartContract } from '..';
|
||||
|
|
|
@ -15,7 +15,7 @@ import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/us
|
|||
import { MonitoringStats } from '../monitoring';
|
||||
import { configSchema, TaskManagerConfig } from '../config';
|
||||
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 mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { getMigrations } from './migrations';
|
||||
import { TaskManagerConfig } from '../config';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
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 { first } from 'rxjs';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import { Subject } from 'rxjs';
|
|||
import { omit, defaults, get } from 'lodash';
|
||||
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 {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 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';
|
||||
|
||||
export interface BuildAggregationOpts {
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
SearchHit,
|
||||
SearchHitsMetadata,
|
||||
AggregationsSingleMetricAggregateBase,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { Group } from '@kbn/observability-alerting-rule-utils';
|
||||
|
||||
export const UngroupedGroupId = 'all documents';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
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 {
|
||||
IExecutionLog,
|
||||
ExecutionLogSortFields,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
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 { INTERNAL_BASE_ALERTING_API_PATH } from '../../constants';
|
||||
import { getFilter } from './get_filter';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
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 {
|
||||
IExecutionLog,
|
||||
ExecutionLogSortFields,
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
EuiCopy,
|
||||
EuiDataGridControlColumn,
|
||||
} 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 type { RuleRegistrySearchRequestPagination } from '@kbn/rule-registry-plugin/common';
|
||||
import type { BrowserFields } from '@kbn/alerting-types';
|
||||
|
@ -27,7 +27,7 @@ import { Storage } from '@kbn/kibana-utils-plugin/public';
|
|||
import type {
|
||||
QueryDslQueryContainer,
|
||||
SortCombinations,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { QueryClientProvider } from '@tanstack/react-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';
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
ALERT_STATUS,
|
||||
TIMESTAMP,
|
||||
} 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 { i18n } from '@kbn/i18n';
|
||||
import { FEATURE_LABEL } from '../translations';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { SortCombinations } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
export const DefaultSort: SortCombinations[] = [
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
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 { ALERT_CASE_IDS, isSiemRuleType } from '@kbn/rule-data-utils';
|
||||
import { AlertsTableContext } from '../contexts/alerts_table_context';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
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 { AlertsQueryContext } from '@kbn/alerts-ui-shared/src/common/contexts/alerts_query_context';
|
||||
import { useKibana } from '../../../../common';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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';
|
||||
|
||||
const DEFAULT_INDEX_PATTERN = [
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { QueryDslQueryContainer, SortCombinations } from '@elastic/elasticsearch/lib/api/types';
|
||||
import {
|
||||
QueryDslQueryContainer,
|
||||
SortCombinations,
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type {
|
||||
EuiDataGridCellPopoverElementProps,
|
||||
EuiDataGridCellProps,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 { Logger } from '@kbn/core/server';
|
||||
import { TimeSeriesQuery, timeSeriesQuery, getResultFromEs } from './time_series_query';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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 type { ElasticsearchClient } from '@kbn/core/server';
|
||||
import { getEsErrorMessage } from '@kbn/alerting-plugin/server';
|
||||
|
|
|
@ -181,12 +181,14 @@ const assertIndexTemplate = (namespace: string) => {
|
|||
expect(createOrUpdateIndexTemplate).toHaveBeenCalledWith({
|
||||
logger,
|
||||
esClient,
|
||||
template: expect.objectContaining({
|
||||
template: {
|
||||
name: `.risk-score.risk-score-${namespace}-index-template`,
|
||||
body: expect.objectContaining({
|
||||
data_stream: { hidden: true },
|
||||
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