@Override
protected CheckResult runCheck() {
this.searchHits = Collections.emptyList();
try {
String filter = "streams:" + stream.getId();
FieldStatsResult fieldStatsResult = searches.fieldStats(field, "*", filter, new RelativeRange(time * 60));
if (getBacklog() != null && getBacklog() > 0) {
this.searchHits = Lists.newArrayList();
for (ResultMessage resultMessage : fieldStatsResult.getSearchHits()) {
this.searchHits.add(new Message(resultMessage.getMessage()));
}
}
if (fieldStatsResult.getCount() == 0) {
LOG.debug("Alert check <{}> did not match any messages. Returning not triggered.", type);
return new CheckResult(false);
}
double result;
switch (type) {
case MEAN:
result = fieldStatsResult.getMean();
break;
case MIN:
result = fieldStatsResult.getMin();
break;
case MAX:
result = fieldStatsResult.getMax();
break;
case SUM:
result = fieldStatsResult.getSum();
break;
case STDDEV:
result = fieldStatsResult.getStdDeviation();
break;
default:
LOG.error("No such field value check type: [{}]. Returning not triggered.", type);
return new CheckResult(false);
}