Skip to content

Commit

Permalink
feat: Added support for notification prompts in AlertPolicy
Browse files Browse the repository at this point in the history
feat: Added support for PromQL metric validation opt-out in AlertPolicy

PiperOrigin-RevId: 702547115
  • Loading branch information
Google APIs authored and copybara-github committed Dec 4, 2024
1 parent 608531f commit dedba31
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 138 deletions.
88 changes: 4 additions & 84 deletions google/monitoring/v3/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
# * extra_protoc_file_parameters
# The complete list of preserved parameters can be found in the source code.

# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])
load("@com_google_googleapis_imports//:imports.bzl", "cc_grpc_library", "cc_proto_library", "csharp_gapic_assembly_pkg", "csharp_gapic_library", "csharp_grpc_library", "csharp_proto_library", "go_gapic_assembly_pkg", "go_gapic_library", "go_proto_library", "java_gapic_assembly_gradle_pkg", "java_gapic_library", "java_gapic_test", "java_grpc_library", "java_proto_library", "nodejs_gapic_assembly_pkg", "nodejs_gapic_library", "php_gapic_assembly_pkg", "php_gapic_library", "php_proto_library", "proto_library_with_info", "py_gapic_assembly_pkg", "py_gapic_library", "ruby_cloud_gapic_library", "ruby_gapic_assembly_pkg", "ruby_grpc_library", "ruby_proto_library")

##############################################################################
# Common
##############################################################################
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")

# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

proto_library(
name = "monitoring_proto",
Expand Down Expand Up @@ -69,18 +70,6 @@ proto_library_with_info(
],
)

##############################################################################
# Java
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"java_gapic_assembly_gradle_pkg",
"java_gapic_library",
"java_gapic_test",
"java_grpc_library",
"java_proto_library",
)

java_proto_library(
name = "monitoring_java_proto",
deps = [":monitoring_proto"],
Expand Down Expand Up @@ -137,16 +126,6 @@ java_gapic_assembly_gradle_pkg(
],
)

##############################################################################
# Go
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"go_gapic_assembly_pkg",
"go_gapic_library",
"go_proto_library",
)

go_proto_library(
name = "monitoring_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
Expand Down Expand Up @@ -196,15 +175,6 @@ go_gapic_assembly_pkg(
],
)

##############################################################################
# Python
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"py_gapic_assembly_pkg",
"py_gapic_library",
)

py_gapic_library(
name = "monitoring_py_gapic",
srcs = [":monitoring_proto"],
Expand Down Expand Up @@ -233,16 +203,6 @@ py_gapic_assembly_pkg(
],
)

##############################################################################
# PHP
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"php_gapic_assembly_pkg",
"php_gapic_library",
"php_proto_library",
)

php_proto_library(
name = "monitoring_php_proto",
deps = [":monitoring_proto"],
Expand All @@ -268,15 +228,6 @@ php_gapic_assembly_pkg(
],
)

##############################################################################
# Node.js
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"nodejs_gapic_assembly_pkg",
"nodejs_gapic_library",
)

nodejs_gapic_library(
name = "monitoring_nodejs_gapic",
package_name = "@google-cloud/monitoring",
Expand All @@ -299,17 +250,6 @@ nodejs_gapic_assembly_pkg(
],
)

##############################################################################
# Ruby
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"ruby_cloud_gapic_library",
"ruby_gapic_assembly_pkg",
"ruby_grpc_library",
"ruby_proto_library",
)

ruby_proto_library(
name = "monitoring_ruby_proto",
deps = [":monitoring_proto"],
Expand Down Expand Up @@ -353,17 +293,6 @@ ruby_gapic_assembly_pkg(
],
)

##############################################################################
# C#
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"csharp_gapic_assembly_pkg",
"csharp_gapic_library",
"csharp_grpc_library",
"csharp_proto_library",
)

csharp_proto_library(
name = "monitoring_csharp_proto",
deps = [":monitoring_proto"],
Expand Down Expand Up @@ -399,15 +328,6 @@ csharp_gapic_assembly_pkg(
],
)

##############################################################################
# C++
##############################################################################
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_grpc_library",
"cc_proto_library",
)

cc_proto_library(
name = "monitoring_cc_proto",
deps = [":monitoring_proto"],
Expand Down
61 changes: 40 additions & 21 deletions google/monitoring/v3/alert.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ option ruby_package = "Google::Cloud::Monitoring::V3";

// 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. For an overview of alert policies, see
// this state. For an overview of alerting policies, see
// [Introduction to Alerting](https://cloud.google.com/monitoring/alerts/).
//
message AlertPolicy {
Expand Down Expand Up @@ -67,7 +67,7 @@ message AlertPolicy {
// 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. This text can be [templatized by using
// variables](https://cloud.google.com/monitoring/alerts/doc-variables).
// variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars).
string content = 1;

// The format of the `content` field. Presently, only the value
Expand All @@ -85,7 +85,7 @@ message AlertPolicy {
// it is common to define textual fields in databases as VARCHAR(255).
//
// The contents of the subject line can be [templatized by using
// variables](https://cloud.google.com/monitoring/alerts/doc-variables).
// variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars).
// If this field is missing or empty, a default subject line will be
// generated.
string subject = 3 [(google.api.field_behavior) = OPTIONAL];
Expand Down Expand Up @@ -323,7 +323,7 @@ message AlertPolicy {
map<string, string> label_extractors = 2;
}

// A condition type that allows alert policies to be defined using
// A condition type that allows alerting policies to be defined using
// [Monitoring Query Language](https://cloud.google.com/monitoring/mql).
message MonitoringQueryLanguageCondition {
// [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
Expand Down Expand Up @@ -355,7 +355,7 @@ message AlertPolicy {
EvaluationMissingData evaluation_missing_data = 4;
}

// A condition type that allows alert policies to be defined using
// A condition type that allows alerting policies to be defined using
// [Prometheus Query Language
// (PromQL)](https://prometheus.io/docs/prometheus/latest/querying/basics/).
//
Expand Down Expand Up @@ -414,7 +414,7 @@ message AlertPolicy {
// Label names [must be
// valid](https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels).
// Label values can be [templatized by using
// variables](https://cloud.google.com/monitoring/alerts/doc-variables).
// variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars).
// The only available variable names are the names of the labels in the
// PromQL result, including "__name__" and "value". "labels" may be empty.
map<string, string> labels = 4 [(google.api.field_behavior) = OPTIONAL];
Expand Down Expand Up @@ -527,13 +527,25 @@ message AlertPolicy {
// Control over how the notification channels in `notification_channels`
// are notified when this alert fires.
message AlertStrategy {
// Control over the rate of notifications sent to this alert policy's
// Control over the rate of notifications sent to this alerting policy's
// notification channels.
message NotificationRateLimit {
// Not more than one notification per `period`.
google.protobuf.Duration period = 1;
}

// Control when notifications will be sent out.
enum NotificationPrompt {
// No strategy specified. Treated as error.
NOTIFICATION_PROMPT_UNSPECIFIED = 0;

// Notify when an incident is opened.
OPENED = 1;

// Notify when an incident is closed.
CLOSED = 3;
}

// Control over how the notification channels in `notification_channels`
// are notified when this alert fires, on a per-channel basis.
message NotificationChannelStrategy {
Expand All @@ -551,20 +563,27 @@ message AlertPolicy {
google.protobuf.Duration renotify_interval = 2;
}

// Required for alert policies with a `LogMatch` condition.
// Required for log-based alerting policies, i.e. policies with a `LogMatch`
// condition.
//
// This limit is not implemented for alert policies that are not log-based.
// This limit is not implemented for alerting policies that do not have
// a LogMatch condition.
NotificationRateLimit notification_rate_limit = 1;

// If an alert policy that was active has no data for this long, any open
// For log-based alert policies, the notification prompts is always
// [OPENED]. For non log-based alert policies, the notification prompts can
// be [OPENED] or [OPENED, CLOSED].
repeated NotificationPrompt notification_prompts = 2;

// If an alerting policy that was active has no data for this long, any open
// incidents will close
google.protobuf.Duration auto_close = 3;

// Control how notifications will be sent out, on a per-channel basis.
repeated NotificationChannelStrategy notification_channel_strategy = 4;
}

// An enumeration of possible severity level for an Alert Policy.
// An enumeration of possible severity level for an alerting policy.
enum Severity {
// No severity is specified. This is the default value.
SEVERITY_UNSPECIFIED = 0;
Expand All @@ -583,8 +602,8 @@ message AlertPolicy {
WARNING = 3;
}

// Required if the policy exists. The resource name for this policy. The
// format is:
// Identifier. Required if the policy exists. The resource name for this
// policy. The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
//
Expand All @@ -593,7 +612,7 @@ message AlertPolicy {
// [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
// method, do not include the `name` field in the alerting policy passed as
// part of the request.
string name = 1;
string name = 1 [(google.api.field_behavior) = IDENTIFIER];

// A short name or phrase used to identify the policy in dashboards,
// notifications, and incidents. To avoid confusion, don't use the same
Expand Down Expand Up @@ -653,9 +672,9 @@ message AlertPolicy {
// a field projection has been specified that strips it out.
google.protobuf.BoolValue enabled = 17;

// Read-only description of how the alert policy is invalid. This field is
// only set when the alert policy is invalid. An invalid alert policy will not
// generate incidents.
// Read-only description of how the alerting policy is invalid. This field is
// only set when the alerting policy is invalid. An invalid alerting policy
// will not generate incidents.
google.rpc.Status validity = 18;

// Identifies the notification channels to which notifications should be sent
Expand All @@ -678,11 +697,11 @@ message AlertPolicy {
// provided in a call to create or update, this field will be ignored.
MutationRecord mutation_record = 11;

// Control over how this alert policy's notification channels are notified.
// Control over how this alerting policy's notification channels are notified.
AlertStrategy alert_strategy = 21;

// Optional. The severity of an alert policy indicates how important incidents
// generated by that policy are. The severity level will be displayed on the
// Incident detail page and in notifications.
// Optional. The severity of an alerting policy indicates how important
// incidents generated by that policy are. The severity level will be
// displayed on the Incident detail page and in notifications.
Severity severity = 22 [(google.api.field_behavior) = OPTIONAL];
}
30 changes: 16 additions & 14 deletions google/monitoring/v3/alert_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,29 @@ message ListAlertPoliciesRequest {
}
];

// If provided, this field specifies the criteria that must be met by
// alert policies to be included in the response.
// Optional. If provided, this field specifies the criteria that must be met
// by alert policies to be included in the response.
//
// For more details, see [sorting and
// filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
string filter = 5;
string filter = 5 [(google.api.field_behavior) = OPTIONAL];

// A comma-separated list of fields by which to sort the result. Supports
// the same set of field references as the `filter` field. Entries can be
// prefixed with a minus sign to sort by the field in descending order.
// Optional. A comma-separated list of fields by which to sort the result.
// Supports the same set of field references as the `filter` field. Entries
// can be prefixed with a minus sign to sort by the field in descending order.
//
// For more details, see [sorting and
// filtering](https://cloud.google.com/monitoring/api/v3/sorting-and-filtering).
string order_by = 6;
string order_by = 6 [(google.api.field_behavior) = OPTIONAL];

// The maximum number of results to return in a single response.
int32 page_size = 2;
// Optional. The maximum number of results to return in a single response.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

// If this field is not empty then it must contain the `nextPageToken` value
// returned by a previous call to this method. Using this field causes the
// method to return more results from the previous method call.
string page_token = 3;
// Optional. If this field is not empty then it must contain the
// `nextPageToken` value returned by a previous call to this method. Using
// this field causes the method to return more results from the previous
// method call.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// The protocol for the `ListAlertPolicies` response.
Expand Down Expand Up @@ -231,7 +232,8 @@ message UpdateAlertPolicyRequest {
// the supplied condition includes the `name` field with that
// `[CONDITION_ID]`. If the supplied condition omits the `name` field,
// then a new `[CONDITION_ID]` is created.
google.protobuf.FieldMask update_mask = 2;
google.protobuf.FieldMask update_mask = 2
[(google.api.field_behavior) = OPTIONAL];

// Required. The updated alerting policy or the updated values for the
// fields listed in `update_mask`.
Expand Down
5 changes: 3 additions & 2 deletions google/monitoring/v3/notification.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";

package google.monitoring.v3;

import "google/api/field_behavior.proto";
import "google/api/label.proto";
import "google/api/launch_stage.proto";
import "google/api/resource.proto";
Expand Down Expand Up @@ -123,12 +124,12 @@ message NotificationChannel {
// field.
string type = 1;

// The full REST resource name for this channel. The format is:
// Identifier. The full REST resource name for this channel. The format is:
//
// projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
//
// The `[CHANNEL_ID]` is automatically assigned by the server on creation.
string name = 6;
string name = 6 [(google.api.field_behavior) = IDENTIFIER];

// An optional human-readable name for this notification channel. It is
// recommended that you specify a non-empty and unique name in order to
Expand Down
Loading

0 comments on commit dedba31

Please sign in to comment.