|
20 | 20 | import com.airbus_cyber_security.graylog.wizard.config.rest.AlertWizardConfig; |
21 | 21 | import com.airbus_cyber_security.graylog.wizard.config.rest.AlertWizardConfigurationService; |
22 | 22 | import com.airbus_cyber_security.graylog.wizard.config.rest.DefaultValues; |
| 23 | +import com.airbus_cyber_security.graylog.wizard.fields.AggregationFieldValueProvider; |
23 | 24 | import com.google.common.collect.ImmutableList; |
| 25 | +import com.google.common.collect.ImmutableMap; |
| 26 | +import org.graylog.events.fields.EventFieldSpec; |
| 27 | +import org.graylog.events.fields.FieldValueType; |
24 | 28 | import org.graylog.events.notifications.EventNotificationHandler; |
25 | 29 | import org.graylog.events.notifications.EventNotificationSettings; |
26 | 30 | import org.graylog.events.processor.DBEventDefinitionService; |
|
35 | 39 | import jakarta.inject.Inject; |
36 | 40 | import java.util.Optional; |
37 | 41 |
|
38 | | -// TODO I am not sure to like this name EventDefinitionHandler? EventDefinitionBusiness? EventDefinitionOperations? |
39 | 42 | public class EventDefinitionService { |
40 | 43 |
|
41 | 44 | private static final Logger LOG = LoggerFactory.getLogger(EventDefinitionService.class); |
| 45 | + private static final String AGGREGATION_TIME_RANGE_FIELD_NAME = "aggregation_id"; |
42 | 46 |
|
43 | 47 | private final EventDefinitionHandler eventDefinitionHandler; |
44 | 48 |
|
@@ -77,13 +81,20 @@ public String createEvent(String alertTitle, String description, Integer priorit |
77 | 81 |
|
78 | 82 | AlertWizardConfig pluginConfiguration = this.configurationService.getConfiguration(); |
79 | 83 | DefaultValues defaultValues = pluginConfiguration.accessDefaultValues(); |
| 84 | + EventFieldSpec aggregationFieldSpec = EventFieldSpec.builder() |
| 85 | + .dataType(FieldValueType.STRING) |
| 86 | + .providers(ImmutableList.of(AggregationFieldValueProvider.Config.builder() |
| 87 | + .aggregationTimeRange(defaultValues.getAggregationTime()) |
| 88 | + .build())) |
| 89 | + .build(); |
80 | 90 | EventDefinitionDto eventDefinition = EventDefinitionDto.builder() |
81 | 91 | .title(alertTitle) |
82 | 92 | .description(description) |
83 | 93 | .config(configuration) |
84 | 94 | .alert(true) |
85 | 95 | .priority(priority) |
86 | 96 | .keySpec(ImmutableList.of()) |
| 97 | + .fieldSpec(ImmutableMap.of(AGGREGATION_TIME_RANGE_FIELD_NAME, aggregationFieldSpec)) |
87 | 98 | .notifications(ImmutableList.<EventNotificationHandler.Config>builder().add(notificationConfiguration).build()) |
88 | 99 | .notificationSettings(EventNotificationSettings.builder() |
89 | 100 | .gracePeriodMs(0L) |
|
0 commit comments