Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Jul 14, 2021
1 parent 17f98ce commit f236e1b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { ComparatorFns, getHumanReadableComparator } from '../lib';

export const ID = '.index-threshold';
export const ActionGroupId = 'threshold met';
const ActionGroupId = 'threshold met';

export function getAlertType(
logger: Logger,
Expand Down Expand Up @@ -180,15 +180,17 @@ export function getAlertType(
groupResult.metrics && groupResult.metrics.length > 0 ? groupResult.metrics[0] : null;
const value = metric && metric.length === 2 ? metric[1] : null;

const met = compareFn(value ?? 0, params.threshold);
if (!value && !met) {
if (value === null) {
logger.debug(
`alert ${ID}:${alertId} "${name}": no metrics found for group ${instanceId}} from groupResult ${JSON.stringify(
groupResult
)}`
);
continue;
}

const met = compareFn(value, params.threshold);

if (!met) continue;

const agg = params.aggField ? `${params.aggType}(${params.aggField})` : `${params.aggType}`;
Expand All @@ -199,7 +201,7 @@ export function getAlertType(
const baseContext: BaseActionContext = {
date,
group: instanceId,
value: value ?? 0,
value,
conditions: humanFn,
};
const actionContext = addMessages(options, baseContext, params);
Expand Down

0 comments on commit f236e1b

Please sign in to comment.