use of com.linkedin.thirdeye.anomaly.alert.util.AnomalyReportGenerator in project pinot by linkedin.
the class EmailResource method generateAndSendAlertForDatasets.
// TODO : add end points for AlertConfig
@GET
@Path("generate/datasets/{startTime}/{endTime}")
public Response generateAndSendAlertForDatasets(@PathParam("startTime") Long startTime, @PathParam("endTime") Long endTime, @QueryParam("datasets") String datasets, @QueryParam("from") String fromAddr, @QueryParam("to") String toAddr, @QueryParam("subject") String subject, @QueryParam("includeSentAnomaliesOnly") boolean includeSentAnomaliesOnly, @QueryParam("teHost") String teHost, @QueryParam("smtpHost") String smtpHost, @QueryParam("smtpPort") int smtpPort) {
if (Strings.isNullOrEmpty(datasets)) {
throw new WebApplicationException("datasets null or empty : " + datasets);
}
String[] dataSetArr = datasets.split(",");
if (dataSetArr.length == 0) {
throw new WebApplicationException("Datasets empty : " + datasets);
}
if (Strings.isNullOrEmpty(toAddr)) {
throw new WebApplicationException("Empty : list of recipients" + toAddr);
}
if (Strings.isNullOrEmpty(teHost)) {
throw new WebApplicationException("Invalid TE host" + teHost);
}
if (Strings.isNullOrEmpty(smtpHost)) {
throw new WebApplicationException("invalid smtp host" + smtpHost);
}
AnomalyReportGenerator anomalyReportGenerator = AnomalyReportGenerator.getInstance();
List<MergedAnomalyResultDTO> anomalies = anomalyReportGenerator.getAnomaliesForDatasets(Arrays.asList(dataSetArr), startTime, endTime);
ThirdEyeAnomalyConfiguration configuration = new ThirdEyeAnomalyConfiguration();
SmtpConfiguration smtpConfiguration = new SmtpConfiguration();
smtpConfiguration.setSmtpHost(smtpHost);
smtpConfiguration.setSmtpPort(smtpPort);
configuration.setSmtpConfiguration(smtpConfiguration);
configuration.setDashboardHost(teHost);
configuration.setPhantomJsPath(thirdeyeConfiguration.getPhantomJsPath());
configuration.setRootDir(thirdeyeConfiguration.getRootDir());
String emailSub = Strings.isNullOrEmpty(subject) ? "Thirdeye Anomaly Report" : subject;
anomalyReportGenerator.buildReport(startTime, endTime, anomalies, emailSub, configuration, includeSentAnomaliesOnly, toAddr, fromAddr, "Thirdeye Anomaly Report", true);
return Response.ok().build();
}
use of com.linkedin.thirdeye.anomaly.alert.util.AnomalyReportGenerator in project pinot by linkedin.
the class EmailResource method generateAndSendAlertForMetrics.
@GET
@Path("generate/metrics/{startTime}/{endTime}")
public Response generateAndSendAlertForMetrics(@PathParam("startTime") Long startTime, @PathParam("endTime") Long endTime, @QueryParam("metrics") String metrics, @QueryParam("from") String fromAddr, @QueryParam("to") String toAddr, @QueryParam("subject") String subject, @QueryParam("includeSentAnomaliesOnly") boolean includeSentAnomaliesOnly, @QueryParam("teHost") String teHost, @QueryParam("smtpHost") String smtpHost, @QueryParam("smtpPort") int smtpPort, @QueryParam("phantomJsPath") String phantomJsPath) {
if (Strings.isNullOrEmpty(metrics)) {
throw new WebApplicationException("metrics null or empty: " + metrics);
}
String[] metricsArr = metrics.split(",");
if (metricsArr.length == 0) {
throw new WebApplicationException("metrics empty : " + metricsArr);
}
if (Strings.isNullOrEmpty(toAddr)) {
throw new WebApplicationException("Empty : list of recipients" + toAddr);
}
if (Strings.isNullOrEmpty(teHost)) {
throw new WebApplicationException("Invalid TE host" + teHost);
}
if (Strings.isNullOrEmpty(smtpHost)) {
throw new WebApplicationException("invalid smtp host" + smtpHost);
}
AnomalyReportGenerator anomalyReportGenerator = AnomalyReportGenerator.getInstance();
List<MergedAnomalyResultDTO> anomalies = anomalyReportGenerator.getAnomaliesForMetrics(Arrays.asList(metricsArr), startTime, endTime);
ThirdEyeAnomalyConfiguration configuration = new ThirdEyeAnomalyConfiguration();
SmtpConfiguration smtpConfiguration = new SmtpConfiguration();
smtpConfiguration.setSmtpHost(smtpHost);
smtpConfiguration.setSmtpPort(smtpPort);
configuration.setSmtpConfiguration(smtpConfiguration);
configuration.setDashboardHost(teHost);
configuration.setPhantomJsPath(phantomJsPath);
String emailSub = Strings.isNullOrEmpty(subject) ? "Thirdeye Anomaly Report" : subject;
anomalyReportGenerator.buildReport(startTime, endTime, anomalies, emailSub, configuration, includeSentAnomaliesOnly, toAddr, fromAddr, "Thirdeye Anomaly Report", true);
return Response.ok().build();
}
Aggregations