Search in sources :

Example 1 with FieldValueProvider

use of org.graylog.events.fields.providers.FieldValueProvider in project graylog2-server by Graylog2.

the class EventFieldSpecEngine method execute.

public void execute(List<EventWithContext> eventsWithContext, Map<String, EventFieldSpec> fieldSpec) {
    for (final Map.Entry<String, EventFieldSpec> entry : fieldSpec.entrySet()) {
        final String fieldName = entry.getKey();
        final EventFieldSpec spec = entry.getValue();
        for (final FieldValueProvider.Config providerConfig : spec.providers()) {
            final FieldValueProvider.Factory providerFactory = fieldValueProviders.get(providerConfig.type());
            if (providerFactory == null) {
                LOG.error("Couldn't find field provider factory for type {}", providerConfig.type());
                continue;
            }
            final FieldValueProvider provider = providerFactory.create(providerConfig);
            for (final EventWithContext eventWithContext : eventsWithContext) {
                final Event event = eventWithContext.event();
                event.setField(fieldName, provider.get(fieldName, eventWithContext));
            }
        }
    }
}
Also used : FieldValueProvider(org.graylog.events.fields.providers.FieldValueProvider) Event(org.graylog.events.event.Event) EventWithContext(org.graylog.events.event.EventWithContext) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 Event (org.graylog.events.event.Event)1 EventWithContext (org.graylog.events.event.EventWithContext)1 FieldValueProvider (org.graylog.events.fields.providers.FieldValueProvider)1