Search in sources :

Example 6 with AlertSummary

use of com.thinkbiganalytics.alerts.api.AlertSummary in project kylo by Teradata.

the class AlertsCache method fetchUnhandledAlerts.

protected List<AlertSummaryGrouped> fetchUnhandledAlerts() {
    List<AlertSummary> alerts = new ArrayList<>();
    AlertCriteria criteria = alertProvider.criteria();
    new AlertCriteriaInput.Builder().state(Alert.State.UNHANDLED).asServiceAccount(true).onlyIfChangesDetected(true).applyToCriteria(criteria);
    Iterator<? extends AlertSummary> itr = alertProvider.getAlertsSummary(criteria);
    if (itr.hasNext()) {
        itr.forEachRemaining(alerts::add);
        List<AlertSummaryGrouped> latestAlerts = new ArrayList<>(alertsModel.groupAlertSummaries(alerts));
        return latestAlerts;
    } else {
        return Collections.emptyList();
    }
}
Also used : AlertCriteria(com.thinkbiganalytics.alerts.api.AlertCriteria) CacheBuilder(com.google.common.cache.CacheBuilder) AlertSummaryGrouped(com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped) ArrayList(java.util.ArrayList) AlertSummary(com.thinkbiganalytics.alerts.api.AlertSummary)

Example 7 with AlertSummary

use of com.thinkbiganalytics.alerts.api.AlertSummary in project kylo by Teradata.

the class FeedsRestController method getAlerts.

private Collection<AlertSummaryGrouped> getAlerts(final String feedName, final String feedId) {
    return metadataAccess.read(() -> {
        String derivedFeedId = feedId;
        // get necessary feed info
        if (StringUtils.isBlank(feedId) && StringUtils.isNotBlank(feedName)) {
            // get the feedId for this feed name
            OpsManagerFeed feed = opsFeedManagerFeedProvider.findByName(feedName);
            if (feed != null) {
                derivedFeedId = feed.getId().toString();
            }
        }
        if (StringUtils.isBlank(derivedFeedId)) {
            return Collections.emptyList();
        }
        List<? extends ServiceLevelAgreementDescription> slas = serviceLevelAgreementDescriptionProvider.findForFeed(opsFeedManagerFeedProvider.resolveId(derivedFeedId));
        List<String> slaIds = new ArrayList<>();
        if (slas != null && !slas.isEmpty()) {
            slaIds = slas.stream().map(sla -> sla.getSlaId().toString()).collect(Collectors.toList());
        }
        List<String> ids = new ArrayList<>();
        ids.addAll(slaIds);
        ids.add(derivedFeedId);
        String filter = ids.stream().collect(Collectors.joining("||"));
        List<AlertSummary> alerts = new ArrayList<>();
        AlertCriteria criteria = alertProvider.criteria().state(Alert.State.UNHANDLED).orFilter(filter);
        alertProvider.getAlertsSummary(criteria).forEachRemaining(alerts::add);
        return alertsModel.groupAlertSummaries(alerts);
    });
}
Also used : AlertCriteria(com.thinkbiganalytics.alerts.api.AlertCriteria) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) ArrayList(java.util.ArrayList) AlertSummary(com.thinkbiganalytics.alerts.api.AlertSummary)

Aggregations

AlertSummary (com.thinkbiganalytics.alerts.api.AlertSummary)7 ArrayList (java.util.ArrayList)6 AlertCriteria (com.thinkbiganalytics.alerts.api.AlertCriteria)4 AlertSummaryGrouped (com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 HashMap (java.util.HashMap)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 AlertConstants (com.thinkbiganalytics.alerts.AlertConstants)1 Alert (com.thinkbiganalytics.alerts.api.Alert)1 EntityAlert (com.thinkbiganalytics.alerts.api.EntityAlert)1 SourceAlert (com.thinkbiganalytics.alerts.api.SourceAlert)1 BaseAlertCriteria (com.thinkbiganalytics.alerts.api.core.BaseAlertCriteria)1 Alert (com.thinkbiganalytics.alerts.rest.model.Alert)1 ObjectMapperSerializer (com.thinkbiganalytics.json.ObjectMapperSerializer)1 EntityAwareAlertSummary (com.thinkbiganalytics.metadata.api.alerts.EntityAwareAlertSummary)1 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)1