Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from azure.mgmt.monitor.models import RuleMetricDataSource, ThresholdRuleCondition, RuleEmailAction
- def storage_blob_90_success(resource_id, resource_name, group_name):
- data_source = RuleMetricDataSource(
- resource_uri=resource_id,
- metric_name='PercentSuccess'
- )
- rule_condition = ThresholdRuleCondition(
- data_source=data_source,
- operator='LessThan',
- threshold=90,
- window_size='PT1H',
- time_aggregation='Average'
- )
- rule_action = RuleEmailAction(
- send_to_service_owners=False,
- custom_emails=[
- 'support@cloudeon.com'
- ]
- )
- group_name = group_name
- rule_name = '90_success_blob_' + resource_name
- my_alert = monitor_client.alert_rules.create_or_update(
- group_name,
- rule_name,
- {
- 'location': 'westeurope',
- 'alert_rule_resource_name': rule_name,
- 'description': 'Successess < 90%',
- 'is_enabled': True,
- 'condition': rule_condition,
- 'actions': [
- rule_action
- ]
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement