Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metricsadvisor] missed data feeds test clean up #19379

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,28 @@ async def _create_data_feed(self, name):
)

async def _create_data_feed_and_detection_config(self, name):
data_feed = await self._create_data_feed(name)
detection_config_name = create_random_name(name)
detection_config = await self.admin_client.create_detection_configuration(
name=detection_config_name,
metric_id=data_feed.metric_ids['cost'],
description="testing",
whole_series_detection_condition=MetricDetectionCondition(
smart_detection_condition=SmartDetectionCondition(
sensitivity=50,
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=5,
min_ratio=5
try:
data_feed = await self._create_data_feed(name)
detection_config_name = create_random_name(name)
detection_config = await self.admin_client.create_detection_configuration(
name=detection_config_name,
metric_id=data_feed.metric_ids['cost'],
description="testing",
whole_series_detection_condition=MetricDetectionCondition(
smart_detection_condition=SmartDetectionCondition(
sensitivity=50,
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=5,
min_ratio=5
)
)
)
)
)
return detection_config, data_feed
return detection_config, data_feed
except Exception as e:
self.admin_client.delete_data_feed(data_feed.id)
raise e

async def _create_data_feed_for_update(self, name):
data_feed_name = create_random_name(name)
Expand Down Expand Up @@ -244,122 +248,130 @@ async def _create_data_feed_for_update(self, name):
)

async def _create_alert_config_for_update(self, name):
detection_config, data_feed = await self._create_data_feed_and_detection_config(name)
alert_config_name = create_random_name(name)
alert_config = await self.admin_client.create_alert_configuration(
name=alert_config_name,
cross_metrics_operator="AND",
metric_alert_configurations=[
MetricAlertConfiguration(
detection_configuration_id=detection_config.id,
alert_scope=MetricAnomalyAlertScope(
scope_type="TopN",
top_n_group_in_scope=TopNGroupScope(
top=5,
period=10,
min_top_count=9
try:
detection_config, data_feed = await self._create_data_feed_and_detection_config(name)
alert_config_name = create_random_name(name)
alert_config = await self.admin_client.create_alert_configuration(
name=alert_config_name,
cross_metrics_operator="AND",
metric_alert_configurations=[
MetricAlertConfiguration(
detection_configuration_id=detection_config.id,
alert_scope=MetricAnomalyAlertScope(
scope_type="TopN",
top_n_group_in_scope=TopNGroupScope(
top=5,
period=10,
min_top_count=9
)
),
alert_conditions=MetricAnomalyAlertConditions(
metric_boundary_condition=MetricBoundaryCondition(
direction="Both",
companion_metric_id=data_feed.metric_ids['cost'],
lower=1.0,
upper=5.0
)
)
),
alert_conditions=MetricAnomalyAlertConditions(
metric_boundary_condition=MetricBoundaryCondition(
direction="Both",
companion_metric_id=data_feed.metric_ids['cost'],
lower=1.0,
upper=5.0
MetricAlertConfiguration(
detection_configuration_id=detection_config.id,
alert_scope=MetricAnomalyAlertScope(
scope_type="SeriesGroup",
series_group_in_scope={'city': 'Shenzhen'}
),
alert_conditions=MetricAnomalyAlertConditions(
severity_condition=SeverityCondition(
min_alert_severity="Low",
max_alert_severity="High"
)
)
)
),
MetricAlertConfiguration(
detection_configuration_id=detection_config.id,
alert_scope=MetricAnomalyAlertScope(
scope_type="SeriesGroup",
series_group_in_scope={'city': 'Shenzhen'}
),
alert_conditions=MetricAnomalyAlertConditions(
severity_condition=SeverityCondition(
min_alert_severity="Low",
max_alert_severity="High"
)
)
),
MetricAlertConfiguration(
detection_configuration_id=detection_config.id,
alert_scope=MetricAnomalyAlertScope(
scope_type="WholeSeries"
),
alert_conditions=MetricAnomalyAlertConditions(
severity_condition=SeverityCondition(
min_alert_severity="Low",
max_alert_severity="High"
MetricAlertConfiguration(
detection_configuration_id=detection_config.id,
alert_scope=MetricAnomalyAlertScope(
scope_type="WholeSeries"
),
alert_conditions=MetricAnomalyAlertConditions(
severity_condition=SeverityCondition(
min_alert_severity="Low",
max_alert_severity="High"
)
)
)
)
],
hook_ids=[]
)
return alert_config, data_feed, detection_config
],
hook_ids=[]
)
return alert_config, data_feed, detection_config
except Exception as e:
self.admin_client.delete_data_feed(data_feed.id)
raise e

async def _create_detection_config_for_update(self, name):
data_feed = await self._create_data_feed(name)
detection_config_name = create_random_name("testupdated")
detection_config = await self.admin_client.create_detection_configuration(
name=detection_config_name,
metric_id=data_feed.metric_ids['cost'],
description="My test metric anomaly detection configuration",
whole_series_detection_condition=MetricDetectionCondition(
condition_operator="AND",
smart_detection_condition=SmartDetectionCondition(
sensitivity=50,
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=5,
min_ratio=5
)
),
hard_threshold_condition=HardThresholdCondition(
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=5,
min_ratio=5
try:
data_feed = await self._create_data_feed(name)
detection_config_name = create_random_name("testupdated")
detection_config = await self.admin_client.create_detection_configuration(
name=detection_config_name,
metric_id=data_feed.metric_ids['cost'],
description="My test metric anomaly detection configuration",
whole_series_detection_condition=MetricDetectionCondition(
condition_operator="AND",
smart_detection_condition=SmartDetectionCondition(
sensitivity=50,
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=5,
min_ratio=5
)
),
lower_bound=0,
upper_bound=100
),
change_threshold_condition=ChangeThresholdCondition(
change_percentage=50,
shift_point=30,
within_range=True,
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=2,
min_ratio=2
hard_threshold_condition=HardThresholdCondition(
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=5,
min_ratio=5
),
lower_bound=0,
upper_bound=100
),
change_threshold_condition=ChangeThresholdCondition(
change_percentage=50,
shift_point=30,
within_range=True,
anomaly_detector_direction="Both",
suppress_condition=SuppressCondition(
min_number=2,
min_ratio=2
)
)
)
),
series_detection_conditions=[MetricSingleSeriesDetectionCondition(
series_key={"city": "Shenzhen", "category": "Jewelry"},
smart_detection_condition=SmartDetectionCondition(
anomaly_detector_direction="Both",
sensitivity=63,
suppress_condition=SuppressCondition(
min_number=1,
min_ratio=100
),
series_detection_conditions=[MetricSingleSeriesDetectionCondition(
series_key={"city": "Shenzhen", "category": "Jewelry"},
smart_detection_condition=SmartDetectionCondition(
anomaly_detector_direction="Both",
sensitivity=63,
suppress_condition=SuppressCondition(
min_number=1,
min_ratio=100
)
)
)
)],
series_group_detection_conditions=[MetricSeriesGroupDetectionCondition(
series_group_key={"city": "Sao Paulo"},
smart_detection_condition=SmartDetectionCondition(
anomaly_detector_direction="Both",
sensitivity=63,
suppress_condition=SuppressCondition(
min_number=1,
min_ratio=100
)],
series_group_detection_conditions=[MetricSeriesGroupDetectionCondition(
series_group_key={"city": "Sao Paulo"},
smart_detection_condition=SmartDetectionCondition(
anomaly_detector_direction="Both",
sensitivity=63,
suppress_condition=SuppressCondition(
min_number=1,
min_ratio=100
)
)
)
)]
)
return detection_config, data_feed
)]
)
return detection_config, data_feed
except Exception as e:
self.admin_client.delete_data_feed(data_feed.id)
raise e

async def _create_email_hook_for_update(self, name):
return await self.admin_client.create_hook(
Expand Down
Loading