use of org.graylog2.notifications.Notification in project graylog2-server by Graylog2.
the class EventNotificationHandlerConfigEntity method toNativeEntity.
@Override
public EventNotificationHandler.Config toNativeEntity(Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> natvieEntities) {
String notificationId = notificationId().asString(parameters);
final EntityDescriptor notificationDescriptor = EntityDescriptor.create(notificationId, ModelTypes.NOTIFICATION_V1);
final Object notification = natvieEntities.get(notificationDescriptor);
final EventNotificationHandler.Config.Builder configBuilder = EventNotificationHandler.Config.builder();
if (notification == null) {
throw new ContentPackException("Missing notification (" + notificationId + ") for event definition");
} else if (notification instanceof NotificationDto) {
NotificationDto notificationDto = (NotificationDto) notification;
configBuilder.notificationId(notificationDto.id());
} else {
throw new ContentPackException("Invalid type for notification (" + notificationId + ") of event definition: " + notification.getClass());
}
return configBuilder.notificationParameters(notificationParameters().orElse(null)).build();
}
use of org.graylog2.notifications.Notification in project graylog2-server by Graylog2.
the class NotificationFacade method exportEntity.
@Override
public Optional<Entity> exportEntity(EntityDescriptor entityDescriptor, EntityDescriptorIds entityDescriptorIds) {
final ModelId modelId = entityDescriptor.id();
final Optional<NotificationDto> notificationDto = notificationService.get(modelId.id());
if (!notificationDto.isPresent()) {
LOG.debug("Couldn't find notification {}", entityDescriptor);
return Optional.empty();
}
final NotificationEntity entity = (NotificationEntity) notificationDto.get().toContentPackEntity(entityDescriptorIds);
final JsonNode data = objectMapper.convertValue(entity, JsonNode.class);
return Optional.of(EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(notificationDto.get().id(), ModelTypes.NOTIFICATION_V1))).type(ModelTypes.NOTIFICATION_V1).data(data).build());
}
use of org.graylog2.notifications.Notification in project graylog2-server by Graylog2.
the class IndexRetentionThread method retentionProblemNotification.
private void retentionProblemNotification(String title, String description) {
final Notification notification = notificationService.buildNow().addNode(nodeId.toString()).addType(Notification.Type.GENERIC).addSeverity(Notification.Severity.URGENT).addDetail("title", title).addDetail("description", description);
notificationService.publishIfFirst(notification);
}
use of org.graylog2.notifications.Notification in project graylog2-server by Graylog2.
the class IndexerClusterCheckerThread method publishDiskUsageNotifications.
private void publishDiskUsageNotifications(Map<Notification.Type, List<String>> notificationTypePerNodeIdentifier) {
for (Map.Entry<Notification.Type, List<String>> entry : notificationTypePerNodeIdentifier.entrySet()) {
if (!notificationExists(entry.getKey())) {
Notification notification = notificationService.buildNow().addType(entry.getKey()).addSeverity(Notification.Severity.URGENT).addDetail("nodes", String.join(", ", entry.getValue()));
notificationService.publishIfFirst(notification);
for (String node : entry.getValue()) {
LOG.warn("Elasticsearch node [{}] triggered [{}] due to low free disk space", node, entry.getKey());
}
}
}
}
use of org.graylog2.notifications.Notification in project graylog2-server by Graylog2.
the class IndexerClusterCheckerThread method checkOpenFiles.
@VisibleForTesting
void checkOpenFiles() {
if (notificationExists(Notification.Type.ES_OPEN_FILES)) {
return;
}
boolean allHigher = true;
final Set<NodeFileDescriptorStats> fileDescriptorStats = cluster.getFileDescriptorStats();
for (NodeFileDescriptorStats nodeFileDescriptorStats : fileDescriptorStats) {
final String name = nodeFileDescriptorStats.name();
final String ip = nodeFileDescriptorStats.ip();
final String host = nodeFileDescriptorStats.host();
final long maxFileDescriptors = nodeFileDescriptorStats.fileDescriptorMax().orElse(-1L);
if (maxFileDescriptors != -1L && maxFileDescriptors < MINIMUM_OPEN_FILES_LIMIT) {
// Write notification.
final String ipOrHostName = firstNonNull(host, ip);
final Notification notification = notificationService.buildNow().addType(Notification.Type.ES_OPEN_FILES).addSeverity(Notification.Severity.URGENT).addDetail("hostname", ipOrHostName).addDetail("max_file_descriptors", maxFileDescriptors);
if (notificationService.publishIfFirst(notification)) {
LOG.warn("Indexer node <{}> ({}) open file limit is too low: [{}]. Set it to at least {}.", name, ipOrHostName, maxFileDescriptors, MINIMUM_OPEN_FILES_LIMIT);
}
allHigher = false;
}
}
if (allHigher) {
Notification notification = notificationService.build().addType(Notification.Type.ES_OPEN_FILES);
notificationService.fixed(notification);
}
}
Aggregations