use of com.linkedin.cruisecontrol.CruiseControlUtils.utcDateFor in project cruise-control by linkedin.
the class AlertaSelfHealingNotifier method alertTopicAnomaly.
private void alertTopicAnomaly(AnomalyType anomalyType, final String localHostname, List<AlertaMessage> alertaMessages, TopicAnomaly topicAnomaly) {
if (topicAnomaly instanceof TopicPartitionSizeAnomaly) {
TopicPartitionSizeAnomaly topicPartitionSizeAnomaly = (TopicPartitionSizeAnomaly) topicAnomaly;
for (Map.Entry<TopicPartition, Double> entry : topicPartitionSizeAnomaly.sizeInMbByPartition().entrySet()) {
AlertaMessage alertaMessage = new AlertaMessage(localHostname, ALERT_MESSAGE_PREFIX_TOPIC_PARTITION_SIZE_ANOMALY + entry.getKey().toString());
alertaMessage.setSeverity(NotifierUtils.getAlertSeverity(anomalyType).toString());
alertaMessage.setGroup(AlertaAlertGroup.PERFORMANCE.toString());
alertaMessage.setValue(String.format("%f MB", entry.getValue()));
alertaMessage.setCreateTime(CruiseControlUtils.utcDateFor(topicAnomaly.detectionTimeMs(), 3, ChronoUnit.SECONDS));
alertaMessages.add(alertaMessage);
}
} else if (topicAnomaly instanceof TopicReplicationFactorAnomaly) {
TopicReplicationFactorAnomaly topicReplicationFactorAnomaly = (TopicReplicationFactorAnomaly) topicAnomaly;
for (Entry<Short, Set<TopicReplicationFactorAnomalyEntry>> entry : topicReplicationFactorAnomaly.badTopicsByDesiredRF().entrySet()) {
entry.getValue().forEach(topicReplicationFactorAnomalyEntry -> {
AlertaMessage alertaMessage = new AlertaMessage(localHostname, ALERT_MESSAGE_PREFIX_TOPIC_REPLICATION_FACTOR_ANOMALY + topicReplicationFactorAnomalyEntry.topicName());
alertaMessage.setSeverity(NotifierUtils.getAlertSeverity(anomalyType).toString());
alertaMessage.setGroup(AlertaAlertGroup.PERFORMANCE.toString());
alertaMessage.setValue(String.format("%.2f", topicReplicationFactorAnomalyEntry.violationRatio()));
alertaMessage.setCreateTime(CruiseControlUtils.utcDateFor(topicAnomaly.detectionTimeMs(), 3, ChronoUnit.SECONDS));
alertaMessages.add(alertaMessage);
});
}
} else {
AlertaMessage alertaMessage = new AlertaMessage(localHostname, anomalyType.toString());
alertaMessage.setSeverity(NotifierUtils.getAlertSeverity(anomalyType).toString());
alertaMessage.setGroup(AlertaAlertGroup.PERFORMANCE.toString());
alertaMessage.setCreateTime(CruiseControlUtils.utcDateFor(topicAnomaly.detectionTimeMs(), 3, ChronoUnit.SECONDS));
alertaMessages.add(alertaMessage);
}
}
Aggregations