Skip to content

Commit

Permalink
Fixes issues from merge with new ES client calls
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Feb 12, 2022
1 parent 1e5698e commit cdfd72f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
SearchRequest,
} from '@elastic/elasticsearch/lib/api/types';
import type { ElasticsearchClient, Logger } from 'kibana/server';
import { ALERT_RULE_UUID } from '@kbn/rule-data-utils';
import type { AlertBucket, AlertAggs } from '../types';

export interface GetAlertsOptions {
Expand All @@ -37,7 +38,7 @@ export const getAlerts = async ({
index: signalsIndex,
keep_alive: keepAlive,
})
).body.id;
).id;

let after: AggregationsCompositeAggregation['after'];
let buckets: AlertBucket[] = [];
Expand All @@ -52,7 +53,7 @@ export const getAlerts = async ({
{
detectionAlerts: {
terms: {
field: 'kibana.alert.rule.uuid',
field: ALERT_RULE_UUID,
},
},
},
Expand Down Expand Up @@ -83,7 +84,7 @@ export const getAlerts = async ({
logger.debug(
`Getting alerts with point in time (PIT) query: ${JSON.stringify(ruleSearchOptions)}`
);
const { body } = await esClient.search<unknown, AlertAggs>(ruleSearchOptions);
const body = await esClient.search<unknown, AlertAggs>(ruleSearchOptions);
if (body.aggregations?.buckets?.buckets != null) {
buckets = [...buckets, ...body.aggregations.buckets.buckets];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const fetchHitsWithPit = async <T>({
index,
keep_alive: '5m',
})
).body.id;
).id;

let searchAfter: SortResults | undefined;
let hits: Array<SearchHit<T>> = [];
Expand All @@ -56,7 +56,7 @@ export const fetchHitsWithPit = async <T>({
logger.debug(
`Getting hits with point in time (PIT) query of: ${JSON.stringify(ruleSearchOptions)}`
);
const { body } = await esClient.search<T>(ruleSearchOptions);
const body = await esClient.search<T>(ruleSearchOptions);
hits = [...hits, ...body.hits.hits];
searchAfter =
body.hits.hits.length !== 0 ? body.hits.hits[body.hits.hits.length - 1].sort : undefined;
Expand Down

0 comments on commit cdfd72f

Please sign in to comment.