diff --git a/command-service/src/command/alert_manager_command.py b/command-service/src/command/alert_manager_command.py index 3b6a82b9..5915a54d 100644 --- a/command-service/src/command/alert_manager_command.py +++ b/command-service/src/command/alert_manager_command.py @@ -5,7 +5,7 @@ from model.data_models import Action, ActionResponse, CommandPayload from service.db_service import DatabaseService from service.http_service import HttpService - +from copy import deepcopy class AlertManagerService(ICommand): @@ -95,17 +95,18 @@ def get_dataset_source_config(self, dataset_id: str) -> str: def get_modified_metric( self, service: str, metric: dict, payload: CommandPayload ) -> dict: + metric_data = deepcopy(metric) if service == "flink": substring = f"{payload.dataset_id}" modified_substring = substring.replace("-", "_") - modified_metric = metric["metric"].replace("dataset_id", modified_substring) - metric["metric"] = modified_metric - return metric + modified_metric = metric_data["metric"].replace("dataset_id", modified_substring) + metric_data["metric"] = modified_metric + return metric_data else: - metric["metric"] = metric["metric"].replace( + metric_data["metric"] = metric_data["metric"].replace( "dataset_id", payload.dataset_id ) - return metric + return metric_data def create_alert_metric( self, payload: CommandPayload, service: str, metric: dict, dataset_name: str