Skip to content

Commit 080e97e

Browse files
committed
Add proto specs for usage alerts
1 parent 1eeb845 commit 080e97e

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

proto/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ proto_library(
432432
],
433433
deps = [
434434
":context_proto",
435+
":user_id_proto",
436+
"@com_google_protobuf//:timestamp_proto",
435437
],
436438
)
437439

@@ -1162,6 +1164,7 @@ go_proto_library(
11621164
proto = ":usage_proto",
11631165
deps = [
11641166
":context_go_proto",
1167+
":user_id_go_proto",
11651168
],
11661169
)
11671170

@@ -2189,6 +2192,8 @@ ts_proto_library(
21892192
proto = ":usage_proto",
21902193
deps = [
21912194
":context_ts_proto",
2195+
":timestamp_ts_proto",
2196+
":user_id_ts_proto",
21922197
],
21932198
)
21942199

proto/usage.proto

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ syntax = "proto3";
33
package usage;
44

55
import "proto/context.proto";
6+
import "proto/user_id.proto";
7+
import "google/protobuf/timestamp.proto";
68

79
message GetUsageRequest {
810
// Request context.
@@ -96,3 +98,109 @@ message Usage {
9698
// ignoring cpu utilization. Idle time is counted.
9799
int64 cloud_workflow_linux_execution_duration_usec = 19;
98100
}
101+
102+
// Alerting rule for usage-based alerts.
103+
message UsageAlertingRule {
104+
// Server-controlled metadata about the rule.
105+
UsageAlertingRuleMetadata metadata = 1;
106+
107+
// User-configured alerting rule configuration.
108+
UsageAlertingRuleConfiguration configuration = 2;
109+
110+
// Evaluator-controlled status for this rule.
111+
UsageAlertingRuleStatus status = 3;
112+
}
113+
114+
// Usage alerting rule metadata.
115+
message UsageAlertingRuleMetadata {
116+
// Unique alerting rule ID (matches a DB row).
117+
string usage_alerting_rule_id = 1;
118+
119+
// User that created the alerting rule.
120+
user_id.DisplayUser created_by_user = 2;
121+
122+
// When the alerting rule was created.
123+
google.protobuf.Timestamp created_timestamp = 3;
124+
}
125+
126+
// User-configurable alerting rule fields. Represents a SKU (optionally filtered
127+
// by labels) as well as a threshold and usage window. If the threshold is
128+
// exceeded, org admins receive an alert stating that the threshold was
129+
// exceeded.
130+
//
131+
// For SKU and label listing, see server/usage/sku/sku.go
132+
message UsageAlertingRuleConfiguration {
133+
// Usage SKU to alert on.
134+
string sku = 1;
135+
136+
// Usage labels to filter on, e.g. {"origin": "internal"}.
137+
map<string, string> labels = 2;
138+
139+
// Alerts are triggered if the usage exceeds this limit.
140+
int64 threshold = 3;
141+
142+
// Usage window over which the alerting threshold applies. This is distinct
143+
// from the server-side evaluation cadence, which is intentionally not
144+
// specified in these API protos.
145+
UsageAlertingWindow window = 4;
146+
}
147+
148+
// Usage alerting rule status.
149+
message UsageAlertingRuleStatus {
150+
// When the alerting rule was last evaluated.
151+
google.protobuf.Timestamp last_evaluation_timestamp = 1;
152+
153+
// When the alerting rule last fired.
154+
google.protobuf.Timestamp last_fired_timestamp = 2;
155+
}
156+
157+
enum UsageAlertingWindow {
158+
USAGE_ALERTING_WINDOW_UNKNOWN = 0;
159+
160+
// UTC day (00:00:00 up to and excluding 00:00:00 the following day).
161+
USAGE_ALERTING_WINDOW_DAY = 1;
162+
163+
// UTC business week (Monday at 00:00:00 up to and excluding the following
164+
// Monday at 00:00:00).
165+
USAGE_ALERTING_WINDOW_WEEK = 2;
166+
167+
// UTC calendar month (the first day of the month at 00:00:00 up to and
168+
// excluding the first day of the following month at 00:00:00).
169+
USAGE_ALERTING_WINDOW_MONTH = 3;
170+
}
171+
172+
message GetUsageAlertingRulesRequest {
173+
context.RequestContext request_context = 1;
174+
}
175+
176+
message GetUsageAlertingRulesResponse {
177+
context.ResponseContext response_context = 1;
178+
179+
// Usage alerting rules owned by the authenticated org.
180+
repeated UsageAlertingRule usage_alerting_rule = 2;
181+
}
182+
183+
message CreateUsageAlertingRuleRequest {
184+
context.RequestContext request_context = 1;
185+
186+
// Alerting rule configuration to create.
187+
UsageAlertingRuleConfiguration configuration = 2;
188+
}
189+
190+
message CreateUsageAlertingRuleResponse {
191+
context.ResponseContext response_context = 1;
192+
193+
// The usage alerting rule that was created.
194+
UsageAlertingRule usage_alerting_rule = 2;
195+
}
196+
197+
message DeleteUsageAlertingRuleRequest {
198+
context.RequestContext request_context = 1;
199+
200+
// Unique alerting rule ID to delete.
201+
string usage_alerting_rule_id = 2;
202+
}
203+
204+
message DeleteUsageAlertingRuleResponse {
205+
context.ResponseContext response_context = 1;
206+
}

0 commit comments

Comments
 (0)