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

[AutoPR monitor/resource-manager] Add dynamic metric alert api #4896

Merged
merged 3 commits into from
Apr 30, 2019
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
12 changes: 9 additions & 3 deletions azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@
from .metric_alert_status_properties_py3 import MetricAlertStatusProperties
from .metric_alert_status_py3 import MetricAlertStatus
from .metric_alert_status_collection_py3 import MetricAlertStatusCollection
from .metric_dimension_py3 import MetricDimension
from .metric_criteria_py3 import MetricCriteria
from .metric_alert_single_resource_multiple_metric_criteria_py3 import MetricAlertSingleResourceMultipleMetricCriteria
from .metric_dimension_py3 import MetricDimension
from .multi_metric_criteria_py3 import MultiMetricCriteria
from .metric_alert_multiple_resource_multiple_metric_criteria_py3 import MetricAlertMultipleResourceMultipleMetricCriteria
from .dynamic_threshold_failing_periods_py3 import DynamicThresholdFailingPeriods
from .dynamic_metric_criteria_py3 import DynamicMetricCriteria
from .source_py3 import Source
from .schedule_py3 import Schedule
from .action_py3 import Action
Expand Down Expand Up @@ -216,11 +218,13 @@
from .metric_alert_status_properties import MetricAlertStatusProperties
from .metric_alert_status import MetricAlertStatus
from .metric_alert_status_collection import MetricAlertStatusCollection
from .metric_dimension import MetricDimension
from .metric_criteria import MetricCriteria
from .metric_alert_single_resource_multiple_metric_criteria import MetricAlertSingleResourceMultipleMetricCriteria
from .metric_dimension import MetricDimension
from .multi_metric_criteria import MultiMetricCriteria
from .metric_alert_multiple_resource_multiple_metric_criteria import MetricAlertMultipleResourceMultipleMetricCriteria
from .dynamic_threshold_failing_periods import DynamicThresholdFailingPeriods
from .dynamic_metric_criteria import DynamicMetricCriteria
from .source import Source
from .schedule import Schedule
from .action import Action
Expand Down Expand Up @@ -372,11 +376,13 @@
'MetricAlertStatusProperties',
'MetricAlertStatus',
'MetricAlertStatusCollection',
'MetricDimension',
'MetricCriteria',
'MetricAlertSingleResourceMultipleMetricCriteria',
'MetricDimension',
'MultiMetricCriteria',
'MetricAlertMultipleResourceMultipleMetricCriteria',
'DynamicThresholdFailingPeriods',
'DynamicMetricCriteria',
'Source',
'Schedule',
'Action',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from .multi_metric_criteria import MultiMetricCriteria


class DynamicMetricCriteria(MultiMetricCriteria):
"""Criterion for dynamic threshold.

All required parameters must be populated in order to send to Azure.

:param additional_properties: Unmatched properties from the message are
deserialized this collection
:type additional_properties: dict[str, object]
:param name: Required. Name of the criteria.
:type name: str
:param metric_name: Required. Name of the metric.
:type metric_name: str
:param metric_namespace: Namespace of the metric.
:type metric_namespace: str
:param time_aggregation: Required. the criteria time aggregation types.
:type time_aggregation: object
:param dimensions: List of dimension conditions.
:type dimensions: list[~azure.mgmt.monitor.models.MetricDimension]
:param criterion_type: Required. Constant filled by server.
:type criterion_type: str
:param operator: Required. The operator used to compare the metric value
against the threshold.
:type operator: object
:param alert_sensitivity: Required. The extent of deviation required to
trigger an alert. This will affect how tight the threshold is to the
metric series pattern.
:type alert_sensitivity: object
:param failing_periods: Required. The minimum number of violations
required within the selected lookback time window required to raise an
alert.
:type failing_periods:
~azure.mgmt.monitor.models.DynamicThresholdFailingPeriods
:param ignore_data_before: Use this option to set the date from which to
start learning the metric historical data and calculate the dynamic
thresholds (in ISO8601 format)
:type ignore_data_before: datetime
"""

_validation = {
'name': {'required': True},
'metric_name': {'required': True},
'time_aggregation': {'required': True},
'criterion_type': {'required': True},
'operator': {'required': True},
'alert_sensitivity': {'required': True},
'failing_periods': {'required': True},
}

_attribute_map = {
'additional_properties': {'key': '', 'type': '{object}'},
'name': {'key': 'name', 'type': 'str'},
'metric_name': {'key': 'metricName', 'type': 'str'},
'metric_namespace': {'key': 'metricNamespace', 'type': 'str'},
'time_aggregation': {'key': 'timeAggregation', 'type': 'object'},
'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'},
'criterion_type': {'key': 'criterionType', 'type': 'str'},
'operator': {'key': 'operator', 'type': 'object'},
'alert_sensitivity': {'key': 'alertSensitivity', 'type': 'object'},
'failing_periods': {'key': 'failingPeriods', 'type': 'DynamicThresholdFailingPeriods'},
'ignore_data_before': {'key': 'ignoreDataBefore', 'type': 'iso-8601'},
}

def __init__(self, **kwargs):
super(DynamicMetricCriteria, self).__init__(**kwargs)
self.operator = kwargs.get('operator', None)
self.alert_sensitivity = kwargs.get('alert_sensitivity', None)
self.failing_periods = kwargs.get('failing_periods', None)
self.ignore_data_before = kwargs.get('ignore_data_before', None)
self.criterion_type = 'DynamicThresholdCriterion'
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from .multi_metric_criteria_py3 import MultiMetricCriteria


class DynamicMetricCriteria(MultiMetricCriteria):
"""Criterion for dynamic threshold.

All required parameters must be populated in order to send to Azure.

:param additional_properties: Unmatched properties from the message are
deserialized this collection
:type additional_properties: dict[str, object]
:param name: Required. Name of the criteria.
:type name: str
:param metric_name: Required. Name of the metric.
:type metric_name: str
:param metric_namespace: Namespace of the metric.
:type metric_namespace: str
:param time_aggregation: Required. the criteria time aggregation types.
:type time_aggregation: object
:param dimensions: List of dimension conditions.
:type dimensions: list[~azure.mgmt.monitor.models.MetricDimension]
:param criterion_type: Required. Constant filled by server.
:type criterion_type: str
:param operator: Required. The operator used to compare the metric value
against the threshold.
:type operator: object
:param alert_sensitivity: Required. The extent of deviation required to
trigger an alert. This will affect how tight the threshold is to the
metric series pattern.
:type alert_sensitivity: object
:param failing_periods: Required. The minimum number of violations
required within the selected lookback time window required to raise an
alert.
:type failing_periods:
~azure.mgmt.monitor.models.DynamicThresholdFailingPeriods
:param ignore_data_before: Use this option to set the date from which to
start learning the metric historical data and calculate the dynamic
thresholds (in ISO8601 format)
:type ignore_data_before: datetime
"""

_validation = {
'name': {'required': True},
'metric_name': {'required': True},
'time_aggregation': {'required': True},
'criterion_type': {'required': True},
'operator': {'required': True},
'alert_sensitivity': {'required': True},
'failing_periods': {'required': True},
}

_attribute_map = {
'additional_properties': {'key': '', 'type': '{object}'},
'name': {'key': 'name', 'type': 'str'},
'metric_name': {'key': 'metricName', 'type': 'str'},
'metric_namespace': {'key': 'metricNamespace', 'type': 'str'},
'time_aggregation': {'key': 'timeAggregation', 'type': 'object'},
'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'},
'criterion_type': {'key': 'criterionType', 'type': 'str'},
'operator': {'key': 'operator', 'type': 'object'},
'alert_sensitivity': {'key': 'alertSensitivity', 'type': 'object'},
'failing_periods': {'key': 'failingPeriods', 'type': 'DynamicThresholdFailingPeriods'},
'ignore_data_before': {'key': 'ignoreDataBefore', 'type': 'iso-8601'},
}

def __init__(self, *, name: str, metric_name: str, time_aggregation, operator, alert_sensitivity, failing_periods, additional_properties=None, metric_namespace: str=None, dimensions=None, ignore_data_before=None, **kwargs) -> None:
super(DynamicMetricCriteria, self).__init__(additional_properties=additional_properties, name=name, metric_name=metric_name, metric_namespace=metric_namespace, time_aggregation=time_aggregation, dimensions=dimensions, **kwargs)
self.operator = operator
self.alert_sensitivity = alert_sensitivity
self.failing_periods = failing_periods
self.ignore_data_before = ignore_data_before
self.criterion_type = 'DynamicThresholdCriterion'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class DynamicThresholdFailingPeriods(Model):
"""The minimum number of violations required within the selected lookback time
window required to raise an alert.

All required parameters must be populated in order to send to Azure.

:param number_of_evaluation_periods: Required. The number of aggregated
lookback points. The lookback time window is calculated based on the
aggregation granularity (windowSize) and the selected number of aggregated
points.
:type number_of_evaluation_periods: float
:param min_failing_periods_to_alert: Required. The number of violations to
trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods.
:type min_failing_periods_to_alert: float
"""

_validation = {
'number_of_evaluation_periods': {'required': True},
'min_failing_periods_to_alert': {'required': True},
}

_attribute_map = {
'number_of_evaluation_periods': {'key': 'numberOfEvaluationPeriods', 'type': 'float'},
'min_failing_periods_to_alert': {'key': 'minFailingPeriodsToAlert', 'type': 'float'},
}

def __init__(self, **kwargs):
super(DynamicThresholdFailingPeriods, self).__init__(**kwargs)
self.number_of_evaluation_periods = kwargs.get('number_of_evaluation_periods', None)
self.min_failing_periods_to_alert = kwargs.get('min_failing_periods_to_alert', None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class DynamicThresholdFailingPeriods(Model):
"""The minimum number of violations required within the selected lookback time
window required to raise an alert.

All required parameters must be populated in order to send to Azure.

:param number_of_evaluation_periods: Required. The number of aggregated
lookback points. The lookback time window is calculated based on the
aggregation granularity (windowSize) and the selected number of aggregated
points.
:type number_of_evaluation_periods: float
:param min_failing_periods_to_alert: Required. The number of violations to
trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods.
:type min_failing_periods_to_alert: float
"""

_validation = {
'number_of_evaluation_periods': {'required': True},
'min_failing_periods_to_alert': {'required': True},
}

_attribute_map = {
'number_of_evaluation_periods': {'key': 'numberOfEvaluationPeriods', 'type': 'float'},
'min_failing_periods_to_alert': {'key': 'minFailingPeriodsToAlert', 'type': 'float'},
}

def __init__(self, *, number_of_evaluation_periods: float, min_failing_periods_to_alert: float, **kwargs) -> None:
super(DynamicThresholdFailingPeriods, self).__init__(**kwargs)
self.number_of_evaluation_periods = number_of_evaluation_periods
self.min_failing_periods_to_alert = min_failing_periods_to_alert
27 changes: 11 additions & 16 deletions azure-mgmt-monitor/azure/mgmt/monitor/models/metric_criteria.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,48 @@ class MetricCriteria(MultiMetricCriteria):
:param additional_properties: Unmatched properties from the message are
deserialized this collection
:type additional_properties: dict[str, object]
:param criterion_type: Required. Constant filled by server.
:type criterion_type: str
:param name: Required. Name of the criteria.
:type name: str
:param metric_name: Required. Name of the metric.
:type metric_name: str
:param metric_namespace: Namespace of the metric.
:type metric_namespace: str
:param operator: Required. the criteria operator.
:type operator: object
:param time_aggregation: Required. the criteria time aggregation types.
:type time_aggregation: object
:param dimensions: List of dimension conditions.
:type dimensions: list[~azure.mgmt.monitor.models.MetricDimension]
:param criterion_type: Required. Constant filled by server.
:type criterion_type: str
:param operator: Required. the criteria operator.
:type operator: object
:param threshold: Required. the criteria threshold value that activates
the alert.
:type threshold: float
:param dimensions: List of dimension conditions.
:type dimensions: list[~azure.mgmt.monitor.models.MetricDimension]
"""

_validation = {
'criterion_type': {'required': True},
'name': {'required': True},
'metric_name': {'required': True},
'operator': {'required': True},
'time_aggregation': {'required': True},
'criterion_type': {'required': True},
'operator': {'required': True},
'threshold': {'required': True},
}

_attribute_map = {
'additional_properties': {'key': '', 'type': '{object}'},
'criterion_type': {'key': 'criterionType', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'metric_name': {'key': 'metricName', 'type': 'str'},
'metric_namespace': {'key': 'metricNamespace', 'type': 'str'},
'operator': {'key': 'operator', 'type': 'object'},
'time_aggregation': {'key': 'timeAggregation', 'type': 'object'},
'threshold': {'key': 'threshold', 'type': 'float'},
'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'},
'criterion_type': {'key': 'criterionType', 'type': 'str'},
'operator': {'key': 'operator', 'type': 'object'},
'threshold': {'key': 'threshold', 'type': 'float'},
}

def __init__(self, **kwargs):
super(MetricCriteria, self).__init__(**kwargs)
self.name = kwargs.get('name', None)
self.metric_name = kwargs.get('metric_name', None)
self.metric_namespace = kwargs.get('metric_namespace', None)
self.operator = kwargs.get('operator', None)
self.time_aggregation = kwargs.get('time_aggregation', None)
self.threshold = kwargs.get('threshold', None)
self.dimensions = kwargs.get('dimensions', None)
self.criterion_type = 'StaticThresholdCriterion'
Loading