All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.graylog2.alerts.AlertService Maven / Gradle / Ivy

There is a newer version: 5.2.7
Show newest version
/**
 * This file is part of Graylog.
 *
 * Graylog is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Graylog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Graylog.  If not, see .
 */
package org.graylog2.alerts;

import org.graylog2.alerts.Alert.AlertState;
import org.graylog2.database.NotFoundException;
import org.graylog2.plugin.alarms.AlertCondition;
import org.graylog2.plugin.configuration.ConfigurationException;
import org.graylog2.plugin.database.ValidationException;
import org.graylog2.plugin.streams.Stream;
import org.graylog2.rest.models.streams.alerts.requests.CreateConditionRequest;
import org.joda.time.DateTime;

import java.util.List;
import java.util.Map;
import java.util.Optional;

public interface AlertService {
    Alert factory(AlertCondition.CheckResult checkResult);

    List loadRecentOfStreams(List streamIds, DateTime since, int limit);
    List loadRecentOfStream(String streamId, DateTime since, int limit);

    Optional getLastTriggeredAlert(String streamId, String conditionId);

    long totalCount();
    long totalCountForStream(String streamId);
    long totalCountForStreams(List streamIds, AlertState state);

    AlertCondition fromPersisted(Map conditionFields, Stream stream) throws ConfigurationException;
    AlertCondition fromRequest(CreateConditionRequest ccr, Stream stream, String userId) throws ConfigurationException;

    AlertCondition updateFromRequest(AlertCondition alertCondition, CreateConditionRequest ccr) throws ConfigurationException;

    boolean inGracePeriod(AlertCondition alertCondition);
    boolean shouldRepeatNotifications(AlertCondition alertCondition, Alert alert);

    List listForStreamId(String streamId, int skip, int limit);
    List listForStreamIds(List streamIds, AlertState state, int skip, int limit);
    Alert load(String alertId, String streamId) throws NotFoundException;
    String save(Alert alert) throws ValidationException;

    Alert resolveAlert(Alert alert);
    boolean isResolved(Alert alert);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy