Skip to content

Commit dedba31

Browse files
Google APIscopybara-github
authored andcommitted
feat: Added support for notification prompts in AlertPolicy
feat: Added support for PromQL metric validation opt-out in AlertPolicy PiperOrigin-RevId: 702547115
1 parent 608531f commit dedba31

6 files changed

Lines changed: 81 additions & 138 deletions

File tree

google/monitoring/v3/BUILD.bazel

Lines changed: 4 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
# * extra_protoc_file_parameters
1010
# The complete list of preserved parameters can be found in the source code.
1111

12-
# This is an API workspace, having public visibility by default makes perfect sense.
13-
package(default_visibility = ["//visibility:public"])
12+
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")
1413

1514
##############################################################################
1615
# Common
1716
##############################################################################
1817
load("@rules_proto//proto:defs.bzl", "proto_library")
19-
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
18+
19+
# This is an API workspace, having public visibility by default makes perfect sense.
20+
package(default_visibility = ["//visibility:public"])
2021

2122
proto_library(
2223
name = "monitoring_proto",
@@ -69,18 +70,6 @@ proto_library_with_info(
6970
],
7071
)
7172

72-
##############################################################################
73-
# Java
74-
##############################################################################
75-
load(
76-
"@com_google_googleapis_imports//:imports.bzl",
77-
"java_gapic_assembly_gradle_pkg",
78-
"java_gapic_library",
79-
"java_gapic_test",
80-
"java_grpc_library",
81-
"java_proto_library",
82-
)
83-
8473
java_proto_library(
8574
name = "monitoring_java_proto",
8675
deps = [":monitoring_proto"],
@@ -137,16 +126,6 @@ java_gapic_assembly_gradle_pkg(
137126
],
138127
)
139128

140-
##############################################################################
141-
# Go
142-
##############################################################################
143-
load(
144-
"@com_google_googleapis_imports//:imports.bzl",
145-
"go_gapic_assembly_pkg",
146-
"go_gapic_library",
147-
"go_proto_library",
148-
)
149-
150129
go_proto_library(
151130
name = "monitoring_go_proto",
152131
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
@@ -196,15 +175,6 @@ go_gapic_assembly_pkg(
196175
],
197176
)
198177

199-
##############################################################################
200-
# Python
201-
##############################################################################
202-
load(
203-
"@com_google_googleapis_imports//:imports.bzl",
204-
"py_gapic_assembly_pkg",
205-
"py_gapic_library",
206-
)
207-
208178
py_gapic_library(
209179
name = "monitoring_py_gapic",
210180
srcs = [":monitoring_proto"],
@@ -233,16 +203,6 @@ py_gapic_assembly_pkg(
233203
],
234204
)
235205

236-
##############################################################################
237-
# PHP
238-
##############################################################################
239-
load(
240-
"@com_google_googleapis_imports//:imports.bzl",
241-
"php_gapic_assembly_pkg",
242-
"php_gapic_library",
243-
"php_proto_library",
244-
)
245-
246206
php_proto_library(
247207
name = "monitoring_php_proto",
248208
deps = [":monitoring_proto"],
@@ -268,15 +228,6 @@ php_gapic_assembly_pkg(
268228
],
269229
)
270230

271-
##############################################################################
272-
# Node.js
273-
##############################################################################
274-
load(
275-
"@com_google_googleapis_imports//:imports.bzl",
276-
"nodejs_gapic_assembly_pkg",
277-
"nodejs_gapic_library",
278-
)
279-
280231
nodejs_gapic_library(
281232
name = "monitoring_nodejs_gapic",
282233
package_name = "@google-cloud/monitoring",
@@ -299,17 +250,6 @@ nodejs_gapic_assembly_pkg(
299250
],
300251
)
301252

302-
##############################################################################
303-
# Ruby
304-
##############################################################################
305-
load(
306-
"@com_google_googleapis_imports//:imports.bzl",
307-
"ruby_cloud_gapic_library",
308-
"ruby_gapic_assembly_pkg",
309-
"ruby_grpc_library",
310-
"ruby_proto_library",
311-
)
312-
313253
ruby_proto_library(
314254
name = "monitoring_ruby_proto",
315255
deps = [":monitoring_proto"],
@@ -353,17 +293,6 @@ ruby_gapic_assembly_pkg(
353293
],
354294
)
355295

356-
##############################################################################
357-
# C#
358-
##############################################################################
359-
load(
360-
"@com_google_googleapis_imports//:imports.bzl",
361-
"csharp_gapic_assembly_pkg",
362-
"csharp_gapic_library",
363-
"csharp_grpc_library",
364-
"csharp_proto_library",
365-
)
366-
367296
csharp_proto_library(
368297
name = "monitoring_csharp_proto",
369298
deps = [":monitoring_proto"],
@@ -399,15 +328,6 @@ csharp_gapic_assembly_pkg(
399328
],
400329
)
401330

402-
##############################################################################
403-
# C++
404-
##############################################################################
405-
load(
406-
"@com_google_googleapis_imports//:imports.bzl",
407-
"cc_grpc_library",
408-
"cc_proto_library",
409-
)
410-
411331
cc_proto_library(
412332
name = "monitoring_cc_proto",
413333
deps = [":monitoring_proto"],

google/monitoring/v3/alert.proto

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ option ruby_package = "Google::Cloud::Monitoring::V3";
3434

3535
// A description of the conditions under which some aspect of your system is
3636
// considered to be "unhealthy" and the ways to notify people or services about
37-
// this state. For an overview of alert policies, see
37+
// this state. For an overview of alerting policies, see
3838
// [Introduction to Alerting](https://cloud.google.com/monitoring/alerts/).
3939
//
4040
message AlertPolicy {
@@ -67,7 +67,7 @@ message AlertPolicy {
6767
// The content may not exceed 8,192 Unicode characters and may not exceed
6868
// more than 10,240 bytes when encoded in UTF-8 format, whichever is
6969
// smaller. This text can be [templatized by using
70-
// variables](https://cloud.google.com/monitoring/alerts/doc-variables).
70+
// variables](https://cloud.google.com/monitoring/alerts/doc-variables#doc-vars).
7171
string content = 1;
7272

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

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

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

537+
// Control when notifications will be sent out.
538+
enum NotificationPrompt {
539+
// No strategy specified. Treated as error.
540+
NOTIFICATION_PROMPT_UNSPECIFIED = 0;
541+
542+
// Notify when an incident is opened.
543+
OPENED = 1;
544+
545+
// Notify when an incident is closed.
546+
CLOSED = 3;
547+
}
548+
537549
// Control over how the notification channels in `notification_channels`
538550
// are notified when this alert fires, on a per-channel basis.
539551
message NotificationChannelStrategy {
@@ -551,20 +563,27 @@ message AlertPolicy {
551563
google.protobuf.Duration renotify_interval = 2;
552564
}
553565

554-
// Required for alert policies with a `LogMatch` condition.
566+
// Required for log-based alerting policies, i.e. policies with a `LogMatch`
567+
// condition.
555568
//
556-
// This limit is not implemented for alert policies that are not log-based.
569+
// This limit is not implemented for alerting policies that do not have
570+
// a LogMatch condition.
557571
NotificationRateLimit notification_rate_limit = 1;
558572

559-
// If an alert policy that was active has no data for this long, any open
573+
// For log-based alert policies, the notification prompts is always
574+
// [OPENED]. For non log-based alert policies, the notification prompts can
575+
// be [OPENED] or [OPENED, CLOSED].
576+
repeated NotificationPrompt notification_prompts = 2;
577+
578+
// If an alerting policy that was active has no data for this long, any open
560579
// incidents will close
561580
google.protobuf.Duration auto_close = 3;
562581

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

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

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

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

656-
// Read-only description of how the alert policy is invalid. This field is
657-
// only set when the alert policy is invalid. An invalid alert policy will not
658-
// generate incidents.
675+
// Read-only description of how the alerting policy is invalid. This field is
676+
// only set when the alerting policy is invalid. An invalid alerting policy
677+
// will not generate incidents.
659678
google.rpc.Status validity = 18;
660679

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

681-
// Control over how this alert policy's notification channels are notified.
700+
// Control over how this alerting policy's notification channels are notified.
682701
AlertStrategy alert_strategy = 21;
683702

684-
// Optional. The severity of an alert policy indicates how important incidents
685-
// generated by that policy are. The severity level will be displayed on the
686-
// Incident detail page and in notifications.
703+
// Optional. The severity of an alerting policy indicates how important
704+
// incidents generated by that policy are. The severity level will be
705+
// displayed on the Incident detail page and in notifications.
687706
Severity severity = 22 [(google.api.field_behavior) = OPTIONAL];
688707
}

google/monitoring/v3/alert_service.proto

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,29 @@ message ListAlertPoliciesRequest {
169169
}
170170
];
171171

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

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

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

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

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

236238
// Required. The updated alerting policy or the updated values for the
237239
// fields listed in `update_mask`.

google/monitoring/v3/notification.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
package google.monitoring.v3;
1818

19+
import "google/api/field_behavior.proto";
1920
import "google/api/label.proto";
2021
import "google/api/launch_stage.proto";
2122
import "google/api/resource.proto";
@@ -123,12 +124,12 @@ message NotificationChannel {
123124
// field.
124125
string type = 1;
125126

126-
// The full REST resource name for this channel. The format is:
127+
// Identifier. The full REST resource name for this channel. The format is:
127128
//
128129
// projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
129130
//
130131
// The `[CHANNEL_ID]` is automatically assigned by the server on creation.
131-
string name = 6;
132+
string name = 6 [(google.api.field_behavior) = IDENTIFIER];
132133

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

0 commit comments

Comments
 (0)