use of org.graylog.plugins.views.search.errors.ParameterExpansionError in project graylog2-server by Graylog2.
the class AggregationEventProcessor method createEvents.
@Override
public void createEvents(EventFactory eventFactory, EventProcessorParameters processorParameters, EventConsumer<List<EventWithContext>> eventsConsumer) throws EventProcessorException {
final AggregationEventProcessorParameters parameters = (AggregationEventProcessorParameters) processorParameters;
// TODO: We have to take the Elasticsearch index.refresh_interval into account here!
if (!dependencyCheck.hasMessagesIndexedUpTo(parameters.timerange().getTo())) {
final String msg = String.format(Locale.ROOT, "Couldn't run aggregation <%s/%s> for timerange <%s to %s> because required messages haven't been indexed, yet.", eventDefinition.title(), eventDefinition.id(), parameters.timerange().getFrom(), parameters.timerange().getTo());
throw new EventProcessorPreconditionException(msg, eventDefinition);
}
LOG.debug("Creating events for config={} parameters={}", config, parameters);
// a simple search query. (one message -> one event)
try {
if (config.series().isEmpty()) {
filterSearch(eventFactory, parameters, eventsConsumer);
} else {
aggregatedSearch(eventFactory, parameters, eventsConsumer);
}
} catch (SearchException e) {
if (e.error() instanceof ParameterExpansionError) {
final String msg = String.format(Locale.ROOT, "Couldn't run aggregation <%s/%s> because parameters failed to expand: %s", eventDefinition.title(), eventDefinition.id(), e.error().description());
LOG.error(msg);
throw new EventProcessorPreconditionException(msg, eventDefinition, e);
}
}
// Update the state for this processor! This state will be used for dependency checks between event processors.
stateService.setState(eventDefinition.id(), parameters.timerange().getFrom(), parameters.timerange().getTo());
}
Aggregations