Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. from azure.mgmt.monitor.models import RuleMetricDataSource, ThresholdRuleCondition, RuleEmailAction
  2.  
  3.  
  4. def storage_blob_90_success(resource_id, resource_name, group_name):
  5. data_source = RuleMetricDataSource(
  6. resource_uri=resource_id,
  7. metric_name='PercentSuccess'
  8. )
  9.  
  10.  
  11. rule_condition = ThresholdRuleCondition(
  12. data_source=data_source,
  13. operator='LessThan',
  14. threshold=90,
  15. window_size='PT1H',
  16. time_aggregation='Average'
  17. )
  18.  
  19.  
  20. rule_action = RuleEmailAction(
  21. send_to_service_owners=False,
  22. custom_emails=[
  23. 'support@cloudeon.com'
  24. ]
  25. )
  26.  
  27.  
  28. group_name = group_name
  29. rule_name = '90_success_blob_' + resource_name
  30. my_alert = monitor_client.alert_rules.create_or_update(
  31. group_name,
  32. rule_name,
  33. {
  34. 'location': 'westeurope',
  35. 'alert_rule_resource_name': rule_name,
  36. 'description': 'Successess < 90%',
  37. 'is_enabled': True,
  38. 'condition': rule_condition,
  39. 'actions': [
  40. rule_action
  41. ]
  42. }
  43. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement