Search in sources :

Example 6 with AlertConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO in project pinot by linkedin.

the class TestAlertConfigManager method testFetchAlertConfig.

@Test(dependsOnMethods = { "testCreateAlertConfig" })
public void testFetchAlertConfig() {
    // find by id
    AlertConfigDTO response = alertConfigDAO.findById(alertConfigid);
    Assert.assertNotNull(response);
    Assert.assertEquals(response.getId(), alertConfigid);
    Assert.assertEquals(alertConfigDAO.findAll().size(), 1);
}
Also used : AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO) Test(org.testng.annotations.Test)

Example 7 with AlertConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO in project pinot by linkedin.

the class RunAdhocDatabaseQueriesTool method playWithAlertCOnfigs.

private void playWithAlertCOnfigs() {
    List<EmailConfigurationDTO> emailConfigs = emailConfigurationDAO.findAll();
    Multimap<String, EmailConfigurationDTO> datasetToEmailConfig = ArrayListMultimap.create();
    for (EmailConfigurationDTO emailConfig : emailConfigs) {
        if (emailConfig.isActive() && !emailConfig.getFunctionIds().isEmpty()) {
            datasetToEmailConfig.put(emailConfig.getCollection(), emailConfig);
        }
    }
    for (String dataset : datasetToEmailConfig.keySet()) {
        List<EmailConfigurationDTO> emailConfigsList = Lists.newArrayList(datasetToEmailConfig.get(dataset));
        String name = "Beta " + dataset + " Alert Config";
        String cron = emailConfigsList.get(0).getCron();
        boolean active = true;
        long watermark = 0L;
        Set<Long> functionIds = new HashSet<>();
        for (EmailConfigurationDTO config : emailConfigsList) {
            functionIds.addAll(config.getFunctionIds());
        }
        EmailConfig emailConfig = new EmailConfig();
        emailConfig.setAnomalyWatermark(watermark);
        emailConfig.setFunctionIds(Lists.newArrayList(functionIds));
        String recipients = "thirdeyeproductteam@linkedin.com";
        String fromAddress = "thirdeye-dev@linkedin.com";
        AlertConfigDTO alertConfig = new AlertConfigDTO();
        alertConfig.setName(name);
        alertConfig.setCronExpression(cron);
        alertConfig.setActive(active);
        alertConfig.setEmailConfig(emailConfig);
        alertConfig.setRecipients(recipients);
        alertConfig.setFromAddress(fromAddress);
        System.out.println(alertConfig);
        alertConfigDAO.save(alertConfig);
    }
}
Also used : EmailConfig(com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean.EmailConfig) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO) HashSet(java.util.HashSet)

Example 8 with AlertConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO in project pinot by linkedin.

the class RunAdhocDatabaseQueriesTool method disableAlertConfigs.

private void disableAlertConfigs() {
    List<AlertConfigDTO> alertConfigs = alertConfigDAO.findAll();
    for (AlertConfigDTO alertConfigDTO : alertConfigs) {
        alertConfigDTO.setActive(false);
        alertConfigDAO.save(alertConfigDTO);
    }
}
Also used : AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)

Example 9 with AlertConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO in project pinot by linkedin.

the class AlertJobRunnerV2 method execute.

@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    LOG.info("Running " + jobExecutionContext.getJobDetail().getKey().toString());
    alertJobContext = (AlertJobContext) jobExecutionContext.getJobDetail().getJobDataMap().get(ALERT_JOB_CONTEXT_V2);
    long alertConfigId = alertJobContext.getAlertConfigId();
    AlertConfigDTO alertConfig = alertConfigDAO.findById(alertConfigId);
    if (alertConfig == null) {
        LOG.error("Alert config with id {} does not exist", alertConfigId);
    } else {
        alertJobContext.setAlertConfigDTO(alertConfig);
        DateTime monitoringWindowStartTime = (DateTime) jobExecutionContext.getJobDetail().getJobDataMap().get(ALERT_JOB_MONITORING_WINDOW_START_TIME);
        DateTime monitoringWindowEndTime = (DateTime) jobExecutionContext.getJobDetail().getJobDataMap().get(ALERT_JOB_MONITORING_WINDOW_END_TIME);
        // Compute window end
        if (monitoringWindowEndTime == null) {
            Date scheduledFireTime = jobExecutionContext.getScheduledFireTime();
            monitoringWindowEndTime = new DateTime(scheduledFireTime);
        }
        // Compute window start according to window end
        if (monitoringWindowStartTime == null) {
            monitoringWindowStartTime = monitoringWindowEndTime;
        }
        // write to alert_jobs
        Long jobExecutionId = createJob(monitoringWindowStartTime, monitoringWindowEndTime);
        alertJobContext.setJobExecutionId(jobExecutionId);
        // write to alert_tasks
        List<Long> taskIds = createTasks(monitoringWindowStartTime, monitoringWindowEndTime);
        LOG.info("Alert V2 tasks created : {}", taskIds);
    }
}
Also used : AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO) DateTime(org.joda.time.DateTime) Date(java.util.Date)

Example 10 with AlertConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO in project pinot by linkedin.

the class AlertJobSchedulerV2 method startJob.

public void startJob(Long id) throws SchedulerException {
    AlertConfigDTO alertConfig = alertConfigDAO.findById(id);
    if (alertConfig == null) {
        throw new IllegalArgumentException("No alert config with id " + id);
    }
    if (!alertConfig.isActive()) {
        throw new IllegalStateException("Alert config with id " + id + " is not active");
    }
    String jobKey = getJobKey(alertConfig.getId());
    startJob(alertConfig, jobKey);
}
Also used : AlertConfigDTO(com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)

Aggregations

AlertConfigDTO (com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)10 EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)2 ArrayList (java.util.ArrayList)2 Test (org.testng.annotations.Test)2 AlertTaskInfo (com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo)1 AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)1 DashboardConfigDTO (com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)1 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)1 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)1 OverrideConfigDTO (com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO)1 AlertConfigBean (com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean)1 EmailConfig (com.linkedin.thirdeye.datalayer.pojo.AlertConfigBean.EmailConfig)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 POST (javax.ws.rs.POST)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 DateTime (org.joda.time.DateTime)1 CronTrigger (org.quartz.CronTrigger)1