Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Jan 27, 2021
1 parent 3fad2dd commit 2380cc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const EsQueryAlertTypeExpression: React.FunctionComponent<
})
);
} catch (err) {
const message = err?.body?.message;
const message = err?.body?.attributes?.error?.root_cause[0]?.reason || err?.body?.message;
setTestQueryError(
i18n.translate('xpack.stackAlerts.esQuery.ui.queryError', {
defaultMessage: 'Error testing query: {message}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { STACK_ALERTS_FEATURE_ID } from '../../../common';
import { ComparatorFns, getHumanReadableComparator } from '../lib';
import { parseDuration } from '../../../../alerts/server';
import { buildSortedEventsQuery } from '../../../common/build_sorted_events_query';
import { ESSearchHit } from '../../../../../typings/elasticsearch';

export const ES_QUERY_ID = '.es-query';

Expand Down Expand Up @@ -231,11 +232,13 @@ export function getAlertType(
// store the params we would need to recreate the query that led to this alert instance
.replaceState({ latestTimestamp: timestamp, dateStart, dateEnd })
.scheduleActions(ActionGroupId, actionContext);
logger.debug(`scheduled actionGroup: ${JSON.stringify(actionContext)}`);

// update the timestamp based on the current search results
const lastTimestamp = searchResult.hits.hits[0]?.sort;
if (lastTimestamp != null && lastTimestamp.length !== 0) {
const firstHitWithSort = searchResult.hits.hits.find(
(hit: ESSearchHit) => hit.sort != null
);
const lastTimestamp = firstHitWithSort?.sort;
if (lastTimestamp != null && lastTimestamp.length > 0) {
timestamp = lastTimestamp[0];
}
}
Expand Down

0 comments on commit 2380cc6

Please sign in to comment.