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);
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations