Publish normalized severity value

Improved the code to allow the component to publish the normalized (0-1) value of severity, rather than (0-100) as of now.

Change-Id: I94a6fdb4612de192c24511445f1236cdce94b405
This commit is contained in:
Andreas Tsagkaropoulos 2024-05-30 14:42:30 +03:00
parent 63d66b73b4
commit 5d7b961957
3 changed files with 12 additions and 3 deletions

View File

@ -33,6 +33,7 @@ public class Constants {
public static String metric_list_topic = "eu.nebulouscloud.monitoring.metric_list";
public static String topic_prefix_realtime_metrics = "eu.nebulouscloud.monitoring.realtime.";
public static String topic_prefix_final_predicted_metrics = "eu.nebulouscloud.monitoring.predicted.";
public static boolean publish_normalized_severity = true;
public static double slo_violation_probability_threshold = 0.5; //The threshold over which the probability of a predicted slo violation should be to have a violation detection
public static int kept_values_per_metric = 5; //Default to be overriden from the configuration file. This indicates how many metric values are kept to calculate the "previous" metric value during the rate of change calculation
public static String roc_calculation_mode = "prototype";

View File

@ -122,8 +122,12 @@ public class DirectorSubcomponent extends SLOViolationDetectorSubcomponent {
Clock clock = Clock.systemUTC();
Long current_time_seconds = (long) Math.floor(clock.millis()/1000.0);
JSONObject severity_json = new JSONObject();
severity_json.put("severity", 100);
severity_json.put("probability", 100);
if (publish_normalized_severity){
severity_json.put("severity", 1.0);
}else{
severity_json.put("severity", 100.0);
}
severity_json.put("probability", 100.0);
severity_json.put("predictionTime", current_time_seconds);
persistent_publisher.publish(severity_json.toJSONString(), Collections.singleton(EMPTY));

View File

@ -157,7 +157,11 @@ public class Runnables {
if (slo_violation_probability >= slo_violation_probability_threshold) {
JSONObject severity_json = new JSONObject();
severity_json.put("severity", rule_severity);
if (publish_normalized_severity) {
severity_json.put("severity", rule_severity/100);
}else{
severity_json.put("severity", rule_severity);
}
severity_json.put("probability", slo_violation_probability);
severity_json.put("predictionTime", targeted_prediction_time);
finalPersistent_publisher.publish(severity_json.toJSONString(), Collections.singleton(detector.get_application_name()));