alert.proto 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.monitoring.v3;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/monitoring/v3/common.proto";
  19. import "google/monitoring/v3/mutation_record.proto";
  20. import "google/protobuf/duration.proto";
  21. import "google/protobuf/wrappers.proto";
  22. import "google/rpc/status.proto";
  23. option csharp_namespace = "Google.Cloud.Monitoring.V3";
  24. option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "AlertProto";
  27. option java_package = "com.google.monitoring.v3";
  28. option php_namespace = "Google\\Cloud\\Monitoring\\V3";
  29. option ruby_package = "Google::Cloud::Monitoring::V3";
  30. // A description of the conditions under which some aspect of your system is
  31. // considered to be "unhealthy" and the ways to notify people or services about
  32. // this state. For an overview of alert policies, see
  33. // [Introduction to Alerting](https://cloud.google.com/monitoring/alerts/).
  34. message AlertPolicy {
  35. option (google.api.resource) = {
  36. type: "monitoring.googleapis.com/AlertPolicy"
  37. pattern: "projects/{project}/alertPolicies/{alert_policy}"
  38. pattern: "organizations/{organization}/alertPolicies/{alert_policy}"
  39. pattern: "folders/{folder}/alertPolicies/{alert_policy}"
  40. pattern: "*"
  41. };
  42. // A content string and a MIME type that describes the content string's
  43. // format.
  44. message Documentation {
  45. // The text of the documentation, interpreted according to `mime_type`.
  46. // The content may not exceed 8,192 Unicode characters and may not exceed
  47. // more than 10,240 bytes when encoded in UTF-8 format, whichever is
  48. // smaller. This text can be [templatized by using
  49. // variables](https://cloud.google.com/monitoring/alerts/doc-variables).
  50. string content = 1;
  51. // The format of the `content` field. Presently, only the value
  52. // `"text/markdown"` is supported. See
  53. // [Markdown](https://en.wikipedia.org/wiki/Markdown) for more information.
  54. string mime_type = 2;
  55. }
  56. // A condition is a true/false test that determines when an alerting policy
  57. // should open an incident. If a condition evaluates to true, it signifies
  58. // that something is wrong.
  59. message Condition {
  60. option (google.api.resource) = {
  61. type: "monitoring.googleapis.com/AlertPolicyCondition"
  62. pattern: "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}"
  63. pattern: "organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}"
  64. pattern: "folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}"
  65. pattern: "*"
  66. };
  67. // Specifies how many time series must fail a predicate to trigger a
  68. // condition. If not specified, then a `{count: 1}` trigger is used.
  69. message Trigger {
  70. // A type of trigger.
  71. oneof type {
  72. // The absolute number of time series that must fail
  73. // the predicate for the condition to be triggered.
  74. int32 count = 1;
  75. // The percentage of time series that must fail the
  76. // predicate for the condition to be triggered.
  77. double percent = 2;
  78. }
  79. }
  80. // A condition control that determines how metric-threshold conditions
  81. // are evaluated when data stops arriving.
  82. // This control doesn't affect metric-absence policies.
  83. enum EvaluationMissingData {
  84. // An unspecified evaluation missing data option. Equivalent to
  85. // EVALUATION_MISSING_DATA_NO_OP.
  86. EVALUATION_MISSING_DATA_UNSPECIFIED = 0;
  87. // If there is no data to evaluate the condition, then evaluate the
  88. // condition as false.
  89. EVALUATION_MISSING_DATA_INACTIVE = 1;
  90. // If there is no data to evaluate the condition, then evaluate the
  91. // condition as true.
  92. EVALUATION_MISSING_DATA_ACTIVE = 2;
  93. // Do not evaluate the condition to any value if there is no data.
  94. EVALUATION_MISSING_DATA_NO_OP = 3;
  95. }
  96. // A condition type that compares a collection of time series
  97. // against a threshold.
  98. message MetricThreshold {
  99. // Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
  100. // identifies which time series should be compared with the threshold.
  101. //
  102. // The filter is similar to the one that is specified in the
  103. // [`ListTimeSeries`
  104. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list)
  105. // (that call is useful to verify the time series that will be retrieved /
  106. // processed). The filter must specify the metric type and the resource
  107. // type. Optionally, it can specify resource labels and metric labels.
  108. // This field must not exceed 2048 Unicode characters in length.
  109. string filter = 2 [(google.api.field_behavior) = REQUIRED];
  110. // Specifies the alignment of data points in individual time series as
  111. // well as how to combine the retrieved time series together (such as
  112. // when aggregating multiple streams on each resource to a single
  113. // stream for each resource or when aggregating streams across all
  114. // members of a group of resources). Multiple aggregations
  115. // are applied in the order specified.
  116. //
  117. // This field is similar to the one in the [`ListTimeSeries`
  118. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list).
  119. // It is advisable to use the `ListTimeSeries` method when debugging this
  120. // field.
  121. repeated Aggregation aggregations = 8;
  122. // A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
  123. // identifies a time series that should be used as the denominator of a
  124. // ratio that will be compared with the threshold. If a
  125. // `denominator_filter` is specified, the time series specified by the
  126. // `filter` field will be used as the numerator.
  127. //
  128. // The filter must specify the metric type and optionally may contain
  129. // restrictions on resource type, resource labels, and metric labels.
  130. // This field may not exceed 2048 Unicode characters in length.
  131. string denominator_filter = 9;
  132. // Specifies the alignment of data points in individual time series
  133. // selected by `denominatorFilter` as
  134. // well as how to combine the retrieved time series together (such as
  135. // when aggregating multiple streams on each resource to a single
  136. // stream for each resource or when aggregating streams across all
  137. // members of a group of resources).
  138. //
  139. // When computing ratios, the `aggregations` and
  140. // `denominator_aggregations` fields must use the same alignment period
  141. // and produce time series that have the same periodicity and labels.
  142. repeated Aggregation denominator_aggregations = 10;
  143. // The comparison to apply between the time series (indicated by `filter`
  144. // and `aggregation`) and the threshold (indicated by `threshold_value`).
  145. // The comparison is applied on each time series, with the time series
  146. // on the left-hand side and the threshold on the right-hand side.
  147. //
  148. // Only `COMPARISON_LT` and `COMPARISON_GT` are supported currently.
  149. ComparisonType comparison = 4;
  150. // A value against which to compare the time series.
  151. double threshold_value = 5;
  152. // The amount of time that a time series must violate the
  153. // threshold to be considered failing. Currently, only values
  154. // that are a multiple of a minute--e.g., 0, 60, 120, or 300
  155. // seconds--are supported. If an invalid value is given, an
  156. // error will be returned. When choosing a duration, it is useful to
  157. // keep in mind the frequency of the underlying time series data
  158. // (which may also be affected by any alignments specified in the
  159. // `aggregations` field); a good duration is long enough so that a single
  160. // outlier does not generate spurious alerts, but short enough that
  161. // unhealthy states are detected and alerted on quickly.
  162. google.protobuf.Duration duration = 6;
  163. // The number/percent of time series for which the comparison must hold
  164. // in order for the condition to trigger. If unspecified, then the
  165. // condition will trigger if the comparison is true for any of the
  166. // time series that have been identified by `filter` and `aggregations`,
  167. // or by the ratio, if `denominator_filter` and `denominator_aggregations`
  168. // are specified.
  169. Trigger trigger = 7;
  170. // A condition control that determines how metric-threshold conditions
  171. // are evaluated when data stops arriving.
  172. EvaluationMissingData evaluation_missing_data = 11;
  173. }
  174. // A condition type that checks that monitored resources
  175. // are reporting data. The configuration defines a metric and
  176. // a set of monitored resources. The predicate is considered in violation
  177. // when a time series for the specified metric of a monitored
  178. // resource does not include any data in the specified `duration`.
  179. message MetricAbsence {
  180. // Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
  181. // identifies which time series should be compared with the threshold.
  182. //
  183. // The filter is similar to the one that is specified in the
  184. // [`ListTimeSeries`
  185. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list)
  186. // (that call is useful to verify the time series that will be retrieved /
  187. // processed). The filter must specify the metric type and the resource
  188. // type. Optionally, it can specify resource labels and metric labels.
  189. // This field must not exceed 2048 Unicode characters in length.
  190. string filter = 1 [(google.api.field_behavior) = REQUIRED];
  191. // Specifies the alignment of data points in individual time series as
  192. // well as how to combine the retrieved time series together (such as
  193. // when aggregating multiple streams on each resource to a single
  194. // stream for each resource or when aggregating streams across all
  195. // members of a group of resources). Multiple aggregations
  196. // are applied in the order specified.
  197. //
  198. // This field is similar to the one in the [`ListTimeSeries`
  199. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list).
  200. // It is advisable to use the `ListTimeSeries` method when debugging this
  201. // field.
  202. repeated Aggregation aggregations = 5;
  203. // The amount of time that a time series must fail to report new
  204. // data to be considered failing. The minimum value of this field
  205. // is 120 seconds. Larger values that are a multiple of a
  206. // minute--for example, 240 or 300 seconds--are supported.
  207. // If an invalid value is given, an
  208. // error will be returned. The `Duration.nanos` field is
  209. // ignored.
  210. google.protobuf.Duration duration = 2;
  211. // The number/percent of time series for which the comparison must hold
  212. // in order for the condition to trigger. If unspecified, then the
  213. // condition will trigger if the comparison is true for any of the
  214. // time series that have been identified by `filter` and `aggregations`.
  215. Trigger trigger = 3;
  216. }
  217. // A condition type that checks whether a log message in the [scoping
  218. // project](https://cloud.google.com/monitoring/api/v3#project_name)
  219. // satisfies the given filter. Logs from other projects in the metrics
  220. // scope are not evaluated.
  221. message LogMatch {
  222. // Required. A logs-based filter. See [Advanced Logs
  223. // Queries](https://cloud.google.com/logging/docs/view/advanced-queries)
  224. // for how this filter should be constructed.
  225. string filter = 1 [(google.api.field_behavior) = REQUIRED];
  226. // Optional. A map from a label key to an extractor expression, which is
  227. // used to extract the value for this label key. Each entry in this map is
  228. // a specification for how data should be extracted from log entries that
  229. // match `filter`. Each combination of extracted values is treated as a
  230. // separate rule for the purposes of triggering notifications. Label keys
  231. // and corresponding values can be used in notifications generated by this
  232. // condition.
  233. //
  234. // Please see [the documentation on logs-based metric
  235. // `valueExtractor`s](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor)
  236. // for syntax and examples.
  237. map<string, string> label_extractors = 2;
  238. }
  239. // A condition type that allows alert policies to be defined using
  240. // [Monitoring Query Language](https://cloud.google.com/monitoring/mql).
  241. message MonitoringQueryLanguageCondition {
  242. // [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
  243. // query that outputs a boolean stream.
  244. string query = 1;
  245. // The amount of time that a time series must violate the
  246. // threshold to be considered failing. Currently, only values
  247. // that are a multiple of a minute--e.g., 0, 60, 120, or 300
  248. // seconds--are supported. If an invalid value is given, an
  249. // error will be returned. When choosing a duration, it is useful to
  250. // keep in mind the frequency of the underlying time series data
  251. // (which may also be affected by any alignments specified in the
  252. // `aggregations` field); a good duration is long enough so that a single
  253. // outlier does not generate spurious alerts, but short enough that
  254. // unhealthy states are detected and alerted on quickly.
  255. google.protobuf.Duration duration = 2;
  256. // The number/percent of time series for which the comparison must hold
  257. // in order for the condition to trigger. If unspecified, then the
  258. // condition will trigger if the comparison is true for any of the
  259. // time series that have been identified by `filter` and `aggregations`,
  260. // or by the ratio, if `denominator_filter` and `denominator_aggregations`
  261. // are specified.
  262. Trigger trigger = 3;
  263. // A condition control that determines how metric-threshold conditions
  264. // are evaluated when data stops arriving.
  265. EvaluationMissingData evaluation_missing_data = 4;
  266. }
  267. // Required if the condition exists. The unique resource name for this
  268. // condition. Its format is:
  269. //
  270. // projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID]
  271. //
  272. // `[CONDITION_ID]` is assigned by Cloud Monitoring when the
  273. // condition is created as part of a new or updated alerting policy.
  274. //
  275. // When calling the
  276. // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
  277. // method, do not include the `name` field in the conditions of the
  278. // requested alerting policy. Cloud Monitoring creates the
  279. // condition identifiers and includes them in the new policy.
  280. //
  281. // When calling the
  282. // [alertPolicies.update][google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy]
  283. // method to update a policy, including a condition `name` causes the
  284. // existing condition to be updated. Conditions without names are added to
  285. // the updated policy. Existing conditions are deleted if they are not
  286. // updated.
  287. //
  288. // Best practice is to preserve `[CONDITION_ID]` if you make only small
  289. // changes, such as those to condition thresholds, durations, or trigger
  290. // values. Otherwise, treat the change as a new condition and let the
  291. // existing condition be deleted.
  292. string name = 12;
  293. // A short name or phrase used to identify the condition in dashboards,
  294. // notifications, and incidents. To avoid confusion, don't use the same
  295. // display name for multiple conditions in the same policy.
  296. string display_name = 6;
  297. // Only one of the following condition types will be specified.
  298. oneof condition {
  299. // A condition that compares a time series against a threshold.
  300. MetricThreshold condition_threshold = 1;
  301. // A condition that checks that a time series continues to
  302. // receive new data points.
  303. MetricAbsence condition_absent = 2;
  304. // A condition that checks for log messages matching given constraints. If
  305. // set, no other conditions can be present.
  306. LogMatch condition_matched_log = 20;
  307. // A condition that uses the Monitoring Query Language to define
  308. // alerts.
  309. MonitoringQueryLanguageCondition condition_monitoring_query_language = 19;
  310. }
  311. }
  312. // Operators for combining conditions.
  313. enum ConditionCombinerType {
  314. // An unspecified combiner.
  315. COMBINE_UNSPECIFIED = 0;
  316. // Combine conditions using the logical `AND` operator. An
  317. // incident is created only if all the conditions are met
  318. // simultaneously. This combiner is satisfied if all conditions are
  319. // met, even if they are met on completely different resources.
  320. AND = 1;
  321. // Combine conditions using the logical `OR` operator. An incident
  322. // is created if any of the listed conditions is met.
  323. OR = 2;
  324. // Combine conditions using logical `AND` operator, but unlike the regular
  325. // `AND` option, an incident is created only if all conditions are met
  326. // simultaneously on at least one resource.
  327. AND_WITH_MATCHING_RESOURCE = 3;
  328. }
  329. // Control over how the notification channels in `notification_channels`
  330. // are notified when this alert fires.
  331. message AlertStrategy {
  332. // Control over the rate of notifications sent to this alert policy's
  333. // notification channels.
  334. message NotificationRateLimit {
  335. // Not more than one notification per `period`.
  336. google.protobuf.Duration period = 1;
  337. }
  338. // Required for alert policies with a `LogMatch` condition.
  339. //
  340. // This limit is not implemented for alert policies that are not log-based.
  341. NotificationRateLimit notification_rate_limit = 1;
  342. // If an alert policy that was active has no data for this long, any open
  343. // incidents will close
  344. google.protobuf.Duration auto_close = 3;
  345. }
  346. // Required if the policy exists. The resource name for this policy. The
  347. // format is:
  348. //
  349. // projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
  350. //
  351. // `[ALERT_POLICY_ID]` is assigned by Cloud Monitoring when the policy
  352. // is created. When calling the
  353. // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
  354. // method, do not include the `name` field in the alerting policy passed as
  355. // part of the request.
  356. string name = 1;
  357. // A short name or phrase used to identify the policy in dashboards,
  358. // notifications, and incidents. To avoid confusion, don't use the same
  359. // display name for multiple policies in the same project. The name is
  360. // limited to 512 Unicode characters.
  361. string display_name = 2;
  362. // Documentation that is included with notifications and incidents related to
  363. // this policy. Best practice is for the documentation to include information
  364. // to help responders understand, mitigate, escalate, and correct the
  365. // underlying problems detected by the alerting policy. Notification channels
  366. // that have limited capacity might not show this documentation.
  367. Documentation documentation = 13;
  368. // User-supplied key/value data to be used for organizing and
  369. // identifying the `AlertPolicy` objects.
  370. //
  371. // The field can contain up to 64 entries. Each key and value is limited to
  372. // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and
  373. // values can contain only lowercase letters, numerals, underscores, and
  374. // dashes. Keys must begin with a letter.
  375. map<string, string> user_labels = 16;
  376. // A list of conditions for the policy. The conditions are combined by AND or
  377. // OR according to the `combiner` field. If the combined conditions evaluate
  378. // to true, then an incident is created. A policy can have from one to six
  379. // conditions.
  380. // If `condition_time_series_query_language` is present, it must be the only
  381. // `condition`.
  382. repeated Condition conditions = 12;
  383. // How to combine the results of multiple conditions to determine if an
  384. // incident should be opened.
  385. // If `condition_time_series_query_language` is present, this must be
  386. // `COMBINE_UNSPECIFIED`.
  387. ConditionCombinerType combiner = 6;
  388. // Whether or not the policy is enabled. On write, the default interpretation
  389. // if unset is that the policy is enabled. On read, clients should not make
  390. // any assumption about the state if it has not been populated. The
  391. // field should always be populated on List and Get operations, unless
  392. // a field projection has been specified that strips it out.
  393. google.protobuf.BoolValue enabled = 17;
  394. // Read-only description of how the alert policy is invalid. OK if the alert
  395. // policy is valid. If not OK, the alert policy will not generate incidents.
  396. google.rpc.Status validity = 18;
  397. // Identifies the notification channels to which notifications should be sent
  398. // when incidents are opened or closed or when new violations occur on
  399. // an already opened incident. Each element of this array corresponds to
  400. // the `name` field in each of the
  401. // [`NotificationChannel`][google.monitoring.v3.NotificationChannel]
  402. // objects that are returned from the [`ListNotificationChannels`]
  403. // [google.monitoring.v3.NotificationChannelService.ListNotificationChannels]
  404. // method. The format of the entries in this field is:
  405. //
  406. // projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
  407. repeated string notification_channels = 14;
  408. // A read-only record of the creation of the alerting policy. If provided
  409. // in a call to create or update, this field will be ignored.
  410. MutationRecord creation_record = 10;
  411. // A read-only record of the most recent change to the alerting policy. If
  412. // provided in a call to create or update, this field will be ignored.
  413. MutationRecord mutation_record = 11;
  414. // Control over how this alert policy's notification channels are notified.
  415. AlertStrategy alert_strategy = 21;
  416. }