diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index 58fcbeee..0eb02fda 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -13,5 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
- digest: sha256:c8878270182edaab99f2927969d4f700c3af265accd472c3425deedff2b7fd93
-# created: 2022-07-14T01:58:16.015625351Z
+ digest: sha256:9db98b055a7f8bd82351238ccaacfd3cda58cdf73012ab58b8da146368330021
+# created: 2022-07-25T16:02:49.174178716Z
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5ff0275..8761b57e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@
[1]: https://pypi.org/project/google-cloud-monitoring/#history
+## [2.11.0](https://github.com/googleapis/python-monitoring/compare/v2.10.1...v2.11.0) (2022-08-06)
+
+
+### Features
+
+* Added support for evaluating missing data in AlertPolicy ([#470](https://github.com/googleapis/python-monitoring/issues/470)) ([71e94c2](https://github.com/googleapis/python-monitoring/commit/71e94c234d500515ed22cc7df031ea0d45153084))
+
+
+### Documentation
+
+* **samples:** add docstrings to explain the project ID format ([#469](https://github.com/googleapis/python-monitoring/issues/469)) ([7009724](https://github.com/googleapis/python-monitoring/commit/700972421378c06951094bbf525ba53c75748a61))
+
## [2.10.1](https://github.com/googleapis/python-monitoring/compare/v2.10.0...v2.10.1) (2022-07-14)
diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py b/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py
index 6a3ce16e..3411e98a 100644
--- a/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py
+++ b/google/cloud/monitoring_v3/services/alert_policy_service/async_client.py
@@ -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 `__, which can
be reached by clicking the "Monitoring" tab in `Cloud
- Console `__.
+ console `__.
"""
_client: AlertPolicyServiceClient
@@ -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.
diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/client.py b/google/cloud/monitoring_v3/services/alert_policy_service/client.py
index a9495812..9e9a1f1b 100644
--- a/google/cloud/monitoring_v3/services/alert_policy_service/client.py
+++ b/google/cloud/monitoring_v3/services/alert_policy_service/client.py
@@ -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 `__, which can
be reached by clicking the "Monitoring" tab in `Cloud
- Console `__.
+ console `__.
"""
@staticmethod
@@ -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.
diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py
index 2b6b4da8..2e0b3ec1 100644
--- a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py
+++ b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc.py
@@ -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 `__, which can
be reached by clicking the "Monitoring" tab in `Cloud
- Console `__.
+ console `__.
This class defines the same methods as the primary client, so the
primary client can load the underlying transport implementation
diff --git a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py
index 510a8924..547b645b 100644
--- a/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py
+++ b/google/cloud/monitoring_v3/services/alert_policy_service/transports/grpc_asyncio.py
@@ -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 `__, which can
be reached by clicking the "Monitoring" tab in `Cloud
- Console `__.
+ console `__.
This class defines the same methods as the primary client, so the
primary client can load the underlying transport implementation
diff --git a/google/cloud/monitoring_v3/types/alert.py b/google/cloud/monitoring_v3/types/alert.py
index 047052d8..ec0e04cf 100644
--- a/google/cloud/monitoring_v3/types/alert.py
+++ b/google/cloud/monitoring_v3/types/alert.py
@@ -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.
@@ -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 `__.
mime_type (str):
The format of the ``content`` field. Presently, only the
value ``"text/markdown"`` is supported. See
@@ -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]
@@ -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.
@@ -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(
@@ -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
@@ -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(
@@ -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,
diff --git a/google/cloud/monitoring_v3/types/alert_service.py b/google/cloud/monitoring_v3/types/alert_service.py
index 76f814da..7cb0b0a3 100644
--- a/google/cloud/monitoring_v3/types/alert_service.py
+++ b/google/cloud/monitoring_v3/types/alert_service.py
@@ -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
diff --git a/noxfile.py b/noxfile.py
index f61f2471..efb03ce7 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -337,7 +337,8 @@ def prerelease_deps(session):
# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
- session.install(*UNIT_TEST_STANDARD_DEPENDENCIES)
+ unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
+ session.install(*unit_deps_all)
system_deps_all = (
SYSTEM_TEST_STANDARD_DEPENDENCIES
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
@@ -366,12 +367,6 @@ def prerelease_deps(session):
session.install(*constraints_deps)
- if os.path.exists("samples/snippets/requirements.txt"):
- session.install("-r", "samples/snippets/requirements.txt")
-
- if os.path.exists("samples/snippets/requirements-test.txt"):
- session.install("-r", "samples/snippets/requirements-test.txt")
-
prerel_deps = [
"protobuf",
# dependency of grpc
@@ -408,11 +403,19 @@ def prerelease_deps(session):
system_test_folder_path = os.path.join("tests", "system")
# Only run system tests if found.
- if os.path.exists(system_test_path) or os.path.exists(system_test_folder_path):
- session.run("py.test", "tests/system")
-
- snippets_test_path = os.path.join("samples", "snippets")
-
- # Only run samples tests if found.
- if os.path.exists(snippets_test_path):
- session.run("py.test", "samples/snippets")
+ if os.path.exists(system_test_path):
+ session.run(
+ "py.test",
+ "--verbose",
+ f"--junitxml=system_{session.python}_sponge_log.xml",
+ system_test_path,
+ *session.posargs,
+ )
+ if os.path.exists(system_test_folder_path):
+ session.run(
+ "py.test",
+ "--verbose",
+ f"--junitxml=system_{session.python}_sponge_log.xml",
+ system_test_folder_path,
+ *session.posargs,
+ )
diff --git a/samples/snippets/v3/alerts-client/requirements.txt b/samples/snippets/v3/alerts-client/requirements.txt
index 1bd61207..d0d171a3 100644
--- a/samples/snippets/v3/alerts-client/requirements.txt
+++ b/samples/snippets/v3/alerts-client/requirements.txt
@@ -1,2 +1,2 @@
-google-cloud-monitoring==2.9.1
-tabulate==0.8.9
+google-cloud-monitoring==2.10.1
+tabulate==0.8.10
diff --git a/samples/snippets/v3/alerts-client/snippets.py b/samples/snippets/v3/alerts-client/snippets.py
index d34e0390..aeaa45a1 100644
--- a/samples/snippets/v3/alerts-client/snippets.py
+++ b/samples/snippets/v3/alerts-client/snippets.py
@@ -27,6 +27,13 @@
# [START monitoring_alert_list_policies]
def list_alert_policies(project_name):
+ """List alert policies in a project.
+
+ Arguments:
+ project_name (str): The Google Cloud Project to use. The project name
+ must be in the format - 'projects/'.
+ """
+
client = monitoring_v3.AlertPolicyServiceClient()
policies = client.list_alert_policies(name=project_name)
print(
@@ -44,6 +51,13 @@ def list_alert_policies(project_name):
# [START monitoring_alert_list_channels]
def list_notification_channels(project_name):
+ """List alert notification channels in a project.
+
+ Arguments:
+ project_name (str): The Google Cloud Project to use. The project name
+ must be in the format - 'projects/'.
+ """
+
client = monitoring_v3.NotificationChannelServiceClient()
channels = client.list_notification_channels(name=project_name)
print(
@@ -62,7 +76,8 @@ def enable_alert_policies(project_name, enable, filter_=None):
"""Enable or disable alert policies in a project.
Arguments:
- project_name (str)
+ project_name (str): The Google Cloud Project to use. The project name
+ must be in the format - 'projects/'.
enable (bool): Enable or disable the policies.
filter_ (str, optional): Only enable/disable alert policies that match
this filter_. See
@@ -95,6 +110,17 @@ def enable_alert_policies(project_name, enable, filter_=None):
# [START monitoring_alert_replace_channels]
def replace_notification_channels(project_name, alert_policy_id, channel_ids):
+ """Replace notification channel of an alert.
+
+ Arguments:
+ project_name (str): The Google Cloud Project to use. The project name
+ must be in the format - 'projects/'.
+ alert_policy_id (str): The ID of the alert policy whose notification
+ channels are to be replaced.
+ channel_ids (str): ID of notification channel to be added as channel
+ for the given alert policy.
+ """
+
_, project_id = project_name.split("/")
alert_client = monitoring_v3.AlertPolicyServiceClient()
channel_client = monitoring_v3.NotificationChannelServiceClient()
@@ -119,6 +145,17 @@ def replace_notification_channels(project_name, alert_policy_id, channel_ids):
# [START monitoring_alert_delete_channel]
def delete_notification_channels(project_name, channel_ids, force=None):
+ """Delete alert notification channels.
+
+ Arguments:
+ project_name (str): The Google Cloud Project to use. The project name
+ must be in the format - 'projects/'.
+ channel_ids list(str): List of IDs of notification channels to delete.
+ force (bool): If true, the notification channels are deleted regardless
+ of its in use by alert policies. If false, channels that are still
+ referenced by an existing alerting policy will fail to be deleted.
+ """
+
channel_client = monitoring_v3.NotificationChannelServiceClient()
for channel_id in channel_ids:
channel_name = "{}/notificationChannels/{}".format(project_name, channel_id)
@@ -136,6 +173,15 @@ def delete_notification_channels(project_name, channel_ids, force=None):
# [START monitoring_alert_backup_policies]
def backup(project_name, backup_filename):
+ """Backup alert policies from a project to a local file.
+
+ Arguments:
+ project_name (str): The Google Cloud Project to use. The project name
+ must be in the format - 'projects/'
+ backup_filename (str): Name of the file (along with its path) to which
+ the alert policies will be written as backup.
+ """
+
alert_client = monitoring_v3.AlertPolicyServiceClient()
channel_client = monitoring_v3.NotificationChannelServiceClient()
record = {
diff --git a/samples/snippets/v3/cloud-client/requirements.txt b/samples/snippets/v3/cloud-client/requirements.txt
index cae18eaa..e1da0e72 100644
--- a/samples/snippets/v3/cloud-client/requirements.txt
+++ b/samples/snippets/v3/cloud-client/requirements.txt
@@ -1 +1 @@
-google-cloud-monitoring==2.9.1
+google-cloud-monitoring==2.10.1
diff --git a/samples/snippets/v3/uptime-check-client/requirements.txt b/samples/snippets/v3/uptime-check-client/requirements.txt
index 1bd61207..d0d171a3 100644
--- a/samples/snippets/v3/uptime-check-client/requirements.txt
+++ b/samples/snippets/v3/uptime-check-client/requirements.txt
@@ -1,2 +1,2 @@
-google-cloud-monitoring==2.9.1
-tabulate==0.8.9
+google-cloud-monitoring==2.10.1
+tabulate==0.8.10
diff --git a/setup.py b/setup.py
index 4577e7b2..0d613f6d 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@
name = "google-cloud-monitoring"
description = "Stackdriver Monitoring API client library"
-version = "2.10.1"
+version = "2.11.0"
# Should be one of:
# 'Development Status :: 3 - Alpha'
# 'Development Status :: 4 - Beta'