From 42ab354465f429fabb9c5f0fa9545455f43da6c3 Mon Sep 17 00:00:00 2001 From: Shashank Reddy Boyapally Date: Mon, 16 Sep 2024 12:09:03 -0400 Subject: [PATCH] added threshold for each metric Signed-off-by: Shashank Reddy Boyapally --- README.md | 8 +++++++- pkg/algorithms/edivisive/edivisive.py | 3 ++- pkg/utils.py | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f6e9d02..173e2fd 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ tests : labels: - "[Jira: PerfScale]" direction: 0 + threshold: 10 - name: apiserverCPU metricName : containerCPU @@ -40,6 +41,7 @@ tests : labels: - "[Jira: kube-apiserver]" direction: 0 + threshold: 10 - name: ovnCPU metricName : containerCPU @@ -51,6 +53,7 @@ tests : labels: - "[Jira: Networking / ovn-kubernetes]" direction: 0 + threshold: 10 - name: etcdCPU metricName : containerCPU @@ -62,6 +65,7 @@ tests : labels: - "[Jira: etcd]" direction: 0 + threshold: 10 - name: etcdDisk metricName : 99thEtcdDiskBackendCommitDurationSeconds @@ -72,6 +76,7 @@ tests : labels: - "[Jira: etcd]" direction: 0 + threshold: 10 - name: kubelet metricName : kubeletCPU @@ -82,9 +87,10 @@ tests : value: cpu agg_type: avg direction: 0 + threshold: 10 ``` -**Note**: `direction: 1` specifies to show positive changes, `direction: 0` specifies to show both positive and negative changes while `direction: -1` shows negative changes. +**Note**: `direction: 1` specifies to show positive changes, `direction: 0` specifies to show both positive and negative changes while `direction: -1` shows negative changes. `threshold` is an absolute value, which allows only changepoints greater than a certain percentage to be detected. ## Build Orion Building Orion is a straightforward process. Follow these commands: diff --git a/pkg/algorithms/edivisive/edivisive.py b/pkg/algorithms/edivisive/edivisive.py index 5d2143a..5e5db81 100644 --- a/pkg/algorithms/edivisive/edivisive.py +++ b/pkg/algorithms/edivisive/edivisive.py @@ -23,7 +23,8 @@ def _analyze(self): for metric, changepoint_list in change_points_by_metric.items(): for i in range(len(changepoint_list)-1, -1, -1): if ((self.metrics_config[metric]["direction"] == 1 and changepoint_list[i].stats.mean_1 > changepoint_list[i].stats.mean_2) or - (self.metrics_config[metric]["direction"] == -1 and changepoint_list[i].stats.mean_1 < changepoint_list[i].stats.mean_2) ): + (self.metrics_config[metric]["direction"] == -1 and changepoint_list[i].stats.mean_1 < changepoint_list[i].stats.mean_2) or + self.metrics_config[metric]["threshold"] > abs((changepoint_list[i].stats.mean_1 - changepoint_list[i].stats.mean_2)/changepoint_list[i].stats.mean_1)*100 ): del changepoint_list[i] if [val for li in change_points_by_metric.values() for val in li]: self.regression_flag=True diff --git a/pkg/utils.py b/pkg/utils.py index e4add5e..bdbb917 100644 --- a/pkg/utils.py +++ b/pkg/utils.py @@ -48,7 +48,7 @@ def get_metric_data( labels = metric.pop("labels", None) direction = int(metric.pop("direction", 0)) - + threshold = abs(int(metric.pop("threshold", 0))) logger_instance.info("Collecting %s", metric_name) try: if "agg" in metric: @@ -58,6 +58,7 @@ def get_metric_data( metric["labels"] = labels metric["direction"] = direction + metric["threshold"] = threshold metrics_config[metric_dataframe_name] = metric dataframe_list.append(metric_df) logger_instance.debug(metric_df)