Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

feat: Added support for evaluating missing data in AlertPolicy #470

Merged
merged 2 commits into from
Aug 6, 2022
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 @@ -45,14 +45,14 @@

class AlertPolicyServiceAsyncClient:
"""The AlertPolicyService API is used to manage (list, create, delete,
edit) alert policies in Stackdriver Monitoring. An alerting policy
is a description of the conditions under which some aspect of your
system is considered to be "unhealthy" and the ways to notify people
or services about this state. In addition to using this API, alert
policies can also be managed through `Stackdriver
edit) alert policies in Cloud Monitoring. An alerting policy is a
description of the conditions under which some aspect of your system
is considered to be "unhealthy" and the ways to notify people or
services about this state. In addition to using this API, alert
policies can also be managed through `Cloud
Monitoring <https://cloud.google.com/monitoring/docs/>`__, which can
be reached by clicking the "Monitoring" tab in `Cloud
Console <https://console.cloud.google.com/>`__.
console <https://console.cloud.google.com/>`__.
"""

_client: AlertPolicyServiceClient
Expand Down Expand Up @@ -511,10 +511,10 @@ async def sample_create_alert_policy():
Note that this field names the parent container in which
the alerting policy will be written, not the name of the
created policy. \|name\| must be a host project of a
workspace, otherwise INVALID_ARGUMENT error will return.
The alerting policy that is returned will have a name
that contains a normalized representation of this name
as a prefix but adds a suffix of the form
Metrics Scope, otherwise INVALID_ARGUMENT error will
return. The alerting policy that is returned will have a
name that contains a normalized representation of this
name as a prefix but adds a suffix of the form
``/alertPolicies/[ALERT_POLICY_ID]``, identifying the
policy in the container.

Expand Down
20 changes: 10 additions & 10 deletions google/cloud/monitoring_v3/services/alert_policy_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def get_transport_class(

class AlertPolicyServiceClient(metaclass=AlertPolicyServiceClientMeta):
"""The AlertPolicyService API is used to manage (list, create, delete,
edit) alert policies in Stackdriver Monitoring. An alerting policy
is a description of the conditions under which some aspect of your
system is considered to be "unhealthy" and the ways to notify people
or services about this state. In addition to using this API, alert
policies can also be managed through `Stackdriver
edit) alert policies in Cloud Monitoring. An alerting policy is a
description of the conditions under which some aspect of your system
is considered to be "unhealthy" and the ways to notify people or
services about this state. In addition to using this API, alert
policies can also be managed through `Cloud
Monitoring <https://cloud.google.com/monitoring/docs/>`__, which can
be reached by clicking the "Monitoring" tab in `Cloud
Console <https://console.cloud.google.com/>`__.
console <https://console.cloud.google.com/>`__.
"""

@staticmethod
Expand Down Expand Up @@ -728,10 +728,10 @@ def sample_create_alert_policy():
Note that this field names the parent container in which
the alerting policy will be written, not the name of the
created policy. \|name\| must be a host project of a
workspace, otherwise INVALID_ARGUMENT error will return.
The alerting policy that is returned will have a name
that contains a normalized representation of this name
as a prefix but adds a suffix of the form
Metrics Scope, otherwise INVALID_ARGUMENT error will
return. The alerting policy that is returned will have a
name that contains a normalized representation of this
name as a prefix but adds a suffix of the form
``/alertPolicies/[ALERT_POLICY_ID]``, identifying the
policy in the container.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class AlertPolicyServiceGrpcTransport(AlertPolicyServiceTransport):
"""gRPC backend transport for AlertPolicyService.

The AlertPolicyService API is used to manage (list, create, delete,
edit) alert policies in Stackdriver Monitoring. An alerting policy
is a description of the conditions under which some aspect of your
system is considered to be "unhealthy" and the ways to notify people
or services about this state. In addition to using this API, alert
policies can also be managed through `Stackdriver
edit) alert policies in Cloud Monitoring. An alerting policy is a
description of the conditions under which some aspect of your system
is considered to be "unhealthy" and the ways to notify people or
services about this state. In addition to using this API, alert
policies can also be managed through `Cloud
Monitoring <https://cloud.google.com/monitoring/docs/>`__, which can
be reached by clicking the "Monitoring" tab in `Cloud
Console <https://console.cloud.google.com/>`__.
console <https://console.cloud.google.com/>`__.

This class defines the same methods as the primary client, so the
primary client can load the underlying transport implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class AlertPolicyServiceGrpcAsyncIOTransport(AlertPolicyServiceTransport):
"""gRPC AsyncIO backend transport for AlertPolicyService.

The AlertPolicyService API is used to manage (list, create, delete,
edit) alert policies in Stackdriver Monitoring. An alerting policy
is a description of the conditions under which some aspect of your
system is considered to be "unhealthy" and the ways to notify people
or services about this state. In addition to using this API, alert
policies can also be managed through `Stackdriver
edit) alert policies in Cloud Monitoring. An alerting policy is a
description of the conditions under which some aspect of your system
is considered to be "unhealthy" and the ways to notify people or
services about this state. In addition to using this API, alert
policies can also be managed through `Cloud
Monitoring <https://cloud.google.com/monitoring/docs/>`__, which can
be reached by clicking the "Monitoring" tab in `Cloud
Console <https://console.cloud.google.com/>`__.
console <https://console.cloud.google.com/>`__.

This class defines the same methods as the primary client, so the
primary client can load the underlying transport implementation
Expand Down
48 changes: 39 additions & 9 deletions google/cloud/monitoring_v3/types/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class AlertPolicy(proto.Message):

projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]

``[ALERT_POLICY_ID]`` is assigned by Stackdriver Monitoring
when the policy is created. When calling the
``[ALERT_POLICY_ID]`` is assigned by Cloud Monitoring when
the policy is created. When calling the
[alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
method, do not include the ``name`` field in the alerting
policy passed as part of the request.
Expand Down Expand Up @@ -146,7 +146,9 @@ class Documentation(proto.Message):
The text of the documentation, interpreted according to
``mime_type``. The content may not exceed 8,192 Unicode
characters and may not exceed more than 10,240 bytes when
encoded in UTF-8 format, whichever is smaller.
encoded in UTF-8 format, whichever is smaller. This text can
be `templatized by using
variables <https://cloud.google.com/monitoring/alerts/doc-variables>`__.
mime_type (str):
The format of the ``content`` field. Presently, only the
value ``"text/markdown"`` is supported. See
Expand Down Expand Up @@ -184,16 +186,16 @@ class Condition(proto.Message):

projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID]

``[CONDITION_ID]`` is assigned by Stackdriver Monitoring
when the condition is created as part of a new or updated
alerting policy.
``[CONDITION_ID]`` is assigned by Cloud Monitoring when the
condition is created as part of a new or updated alerting
policy.

When calling the
[alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
method, do not include the ``name`` field in the conditions
of the requested alerting policy. Stackdriver Monitoring
creates the condition identifiers and includes them in the
new policy.
of the requested alerting policy. Cloud Monitoring creates
the condition identifiers and includes them in the new
policy.

When calling the
[alertPolicies.update][google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy]
Expand Down Expand Up @@ -235,6 +237,16 @@ class Condition(proto.Message):
This field is a member of `oneof`_ ``condition``.
"""

class EvaluationMissingData(proto.Enum):
r"""A condition control that determines how metric-threshold
conditions are evaluated when data stops arriving.
This control doesn't affect metric-absence policies.
"""
EVALUATION_MISSING_DATA_UNSPECIFIED = 0
EVALUATION_MISSING_DATA_INACTIVE = 1
EVALUATION_MISSING_DATA_ACTIVE = 2
EVALUATION_MISSING_DATA_NO_OP = 3

class Trigger(proto.Message):
r"""Specifies how many time series must fail a predicate to trigger a
condition. If not specified, then a ``{count: 1}`` trigger is used.
Expand Down Expand Up @@ -360,6 +372,10 @@ class MetricThreshold(proto.Message):
identified by ``filter`` and ``aggregations``, or by the
ratio, if ``denominator_filter`` and
``denominator_aggregations`` are specified.
evaluation_missing_data (google.cloud.monitoring_v3.types.AlertPolicy.Condition.EvaluationMissingData):
A condition control that determines how
metric-threshold conditions are evaluated when
data stops arriving.
"""

filter = proto.Field(
Expand Down Expand Up @@ -399,6 +415,11 @@ class MetricThreshold(proto.Message):
number=7,
message="AlertPolicy.Condition.Trigger",
)
evaluation_missing_data = proto.Field(
proto.ENUM,
number=11,
enum="AlertPolicy.Condition.EvaluationMissingData",
)

class MetricAbsence(proto.Message):
r"""A condition type that checks that monitored resources are reporting
Expand Down Expand Up @@ -536,6 +557,10 @@ class MonitoringQueryLanguageCondition(proto.Message):
identified by ``filter`` and ``aggregations``, or by the
ratio, if ``denominator_filter`` and
``denominator_aggregations`` are specified.
evaluation_missing_data (google.cloud.monitoring_v3.types.AlertPolicy.Condition.EvaluationMissingData):
A condition control that determines how
metric-threshold conditions are evaluated when
data stops arriving.
"""

query = proto.Field(
Expand All @@ -552,6 +577,11 @@ class MonitoringQueryLanguageCondition(proto.Message):
number=3,
message="AlertPolicy.Condition.Trigger",
)
evaluation_missing_data = proto.Field(
proto.ENUM,
number=4,
enum="AlertPolicy.Condition.EvaluationMissingData",
)

name = proto.Field(
proto.STRING,
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/monitoring_v3/types/alert_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CreateAlertPolicyRequest(proto.Message):

Note that this field names the parent container in which the
alerting policy will be written, not the name of the created
policy. \|name\| must be a host project of a workspace,
policy. \|name\| must be a host project of a Metrics Scope,
otherwise INVALID_ARGUMENT error will return. The alerting
policy that is returned will have a name that contains a
normalized representation of this name as a prefix but adds
Expand Down