alert.proto 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. // Copyright 2021 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.
  49. string content = 1;
  50. // The format of the `content` field. Presently, only the value
  51. // `"text/markdown"` is supported. See
  52. // [Markdown](https://en.wikipedia.org/wiki/Markdown) for more information.
  53. string mime_type = 2;
  54. }
  55. // A condition is a true/false test that determines when an alerting policy
  56. // should open an incident. If a condition evaluates to true, it signifies
  57. // that something is wrong.
  58. message Condition {
  59. option (google.api.resource) = {
  60. type: "monitoring.googleapis.com/AlertPolicyCondition"
  61. pattern: "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}"
  62. pattern: "organizations/{organization}/alertPolicies/{alert_policy}/conditions/{condition}"
  63. pattern: "folders/{folder}/alertPolicies/{alert_policy}/conditions/{condition}"
  64. pattern: "*"
  65. };
  66. // Specifies how many time series must fail a predicate to trigger a
  67. // condition. If not specified, then a `{count: 1}` trigger is used.
  68. message Trigger {
  69. // A type of trigger.
  70. oneof type {
  71. // The absolute number of time series that must fail
  72. // the predicate for the condition to be triggered.
  73. int32 count = 1;
  74. // The percentage of time series that must fail the
  75. // predicate for the condition to be triggered.
  76. double percent = 2;
  77. }
  78. }
  79. // A condition type that compares a collection of time series
  80. // against a threshold.
  81. message MetricThreshold {
  82. // Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
  83. // identifies which time series should be compared with the threshold.
  84. //
  85. // The filter is similar to the one that is specified in the
  86. // [`ListTimeSeries`
  87. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list)
  88. // (that call is useful to verify the time series that will be retrieved /
  89. // processed). The filter must specify the metric type and the resource
  90. // type. Optionally, it can specify resource labels and metric labels.
  91. // This field must not exceed 2048 Unicode characters in length.
  92. string filter = 2 [(google.api.field_behavior) = REQUIRED];
  93. // Specifies the alignment of data points in individual time series as
  94. // well as how to combine the retrieved time series together (such as
  95. // when aggregating multiple streams on each resource to a single
  96. // stream for each resource or when aggregating streams across all
  97. // members of a group of resrouces). Multiple aggregations
  98. // are applied in the order specified.
  99. //
  100. // This field is similar to the one in the [`ListTimeSeries`
  101. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list).
  102. // It is advisable to use the `ListTimeSeries` method when debugging this
  103. // field.
  104. repeated Aggregation aggregations = 8;
  105. // A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
  106. // identifies a time series that should be used as the denominator of a
  107. // ratio that will be compared with the threshold. If a
  108. // `denominator_filter` is specified, the time series specified by the
  109. // `filter` field will be used as the numerator.
  110. //
  111. // The filter must specify the metric type and optionally may contain
  112. // restrictions on resource type, resource labels, and metric labels.
  113. // This field may not exceed 2048 Unicode characters in length.
  114. string denominator_filter = 9;
  115. // Specifies the alignment of data points in individual time series
  116. // selected by `denominatorFilter` as
  117. // well as how to combine the retrieved time series together (such as
  118. // when aggregating multiple streams on each resource to a single
  119. // stream for each resource or when aggregating streams across all
  120. // members of a group of resources).
  121. //
  122. // When computing ratios, the `aggregations` and
  123. // `denominator_aggregations` fields must use the same alignment period
  124. // and produce time series that have the same periodicity and labels.
  125. repeated Aggregation denominator_aggregations = 10;
  126. // The comparison to apply between the time series (indicated by `filter`
  127. // and `aggregation`) and the threshold (indicated by `threshold_value`).
  128. // The comparison is applied on each time series, with the time series
  129. // on the left-hand side and the threshold on the right-hand side.
  130. //
  131. // Only `COMPARISON_LT` and `COMPARISON_GT` are supported currently.
  132. ComparisonType comparison = 4;
  133. // A value against which to compare the time series.
  134. double threshold_value = 5;
  135. // The amount of time that a time series must violate the
  136. // threshold to be considered failing. Currently, only values
  137. // that are a multiple of a minute--e.g., 0, 60, 120, or 300
  138. // seconds--are supported. If an invalid value is given, an
  139. // error will be returned. When choosing a duration, it is useful to
  140. // keep in mind the frequency of the underlying time series data
  141. // (which may also be affected by any alignments specified in the
  142. // `aggregations` field); a good duration is long enough so that a single
  143. // outlier does not generate spurious alerts, but short enough that
  144. // unhealthy states are detected and alerted on quickly.
  145. google.protobuf.Duration duration = 6;
  146. // The number/percent of time series for which the comparison must hold
  147. // in order for the condition to trigger. If unspecified, then the
  148. // condition will trigger if the comparison is true for any of the
  149. // time series that have been identified by `filter` and `aggregations`,
  150. // or by the ratio, if `denominator_filter` and `denominator_aggregations`
  151. // are specified.
  152. Trigger trigger = 7;
  153. }
  154. // A condition type that checks that monitored resources
  155. // are reporting data. The configuration defines a metric and
  156. // a set of monitored resources. The predicate is considered in violation
  157. // when a time series for the specified metric of a monitored
  158. // resource does not include any data in the specified `duration`.
  159. message MetricAbsence {
  160. // Required. A [filter](https://cloud.google.com/monitoring/api/v3/filters) that
  161. // identifies which time series should be compared with the threshold.
  162. //
  163. // The filter is similar to the one that is specified in the
  164. // [`ListTimeSeries`
  165. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list)
  166. // (that call is useful to verify the time series that will be retrieved /
  167. // processed). The filter must specify the metric type and the resource
  168. // type. Optionally, it can specify resource labels and metric labels.
  169. // This field must not exceed 2048 Unicode characters in length.
  170. string filter = 1 [(google.api.field_behavior) = REQUIRED];
  171. // Specifies the alignment of data points in individual time series as
  172. // well as how to combine the retrieved time series together (such as
  173. // when aggregating multiple streams on each resource to a single
  174. // stream for each resource or when aggregating streams across all
  175. // members of a group of resrouces). Multiple aggregations
  176. // are applied in the order specified.
  177. //
  178. // This field is similar to the one in the [`ListTimeSeries`
  179. // request](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list).
  180. // It is advisable to use the `ListTimeSeries` method when debugging this
  181. // field.
  182. repeated Aggregation aggregations = 5;
  183. // The amount of time that a time series must fail to report new
  184. // data to be considered failing. The minimum value of this field
  185. // is 120 seconds. Larger values that are a multiple of a
  186. // minute--for example, 240 or 300 seconds--are supported.
  187. // If an invalid value is given, an
  188. // error will be returned. The `Duration.nanos` field is
  189. // ignored.
  190. google.protobuf.Duration duration = 2;
  191. // The number/percent of time series for which the comparison must hold
  192. // in order for the condition to trigger. If unspecified, then the
  193. // condition will trigger if the comparison is true for any of the
  194. // time series that have been identified by `filter` and `aggregations`.
  195. Trigger trigger = 3;
  196. }
  197. // A condition type that allows alert policies to be defined using
  198. // [Monitoring Query Language](https://cloud.google.com/monitoring/mql).
  199. message MonitoringQueryLanguageCondition {
  200. // [Monitoring Query Language](https://cloud.google.com/monitoring/mql)
  201. // query that outputs a boolean stream.
  202. string query = 1;
  203. // The amount of time that a time series must violate the
  204. // threshold to be considered failing. Currently, only values
  205. // that are a multiple of a minute--e.g., 0, 60, 120, or 300
  206. // seconds--are supported. If an invalid value is given, an
  207. // error will be returned. When choosing a duration, it is useful to
  208. // keep in mind the frequency of the underlying time series data
  209. // (which may also be affected by any alignments specified in the
  210. // `aggregations` field); a good duration is long enough so that a single
  211. // outlier does not generate spurious alerts, but short enough that
  212. // unhealthy states are detected and alerted on quickly.
  213. google.protobuf.Duration duration = 2;
  214. // The number/percent of time series for which the comparison must hold
  215. // in order for the condition to trigger. If unspecified, then the
  216. // condition will trigger if the comparison is true for any of the
  217. // time series that have been identified by `filter` and `aggregations`,
  218. // or by the ratio, if `denominator_filter` and `denominator_aggregations`
  219. // are specified.
  220. Trigger trigger = 3;
  221. }
  222. // Required if the condition exists. The unique resource name for this
  223. // condition. Its format is:
  224. //
  225. // projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[POLICY_ID]/conditions/[CONDITION_ID]
  226. //
  227. // `[CONDITION_ID]` is assigned by Stackdriver Monitoring when the
  228. // condition is created as part of a new or updated alerting policy.
  229. //
  230. // When calling the
  231. // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
  232. // method, do not include the `name` field in the conditions of the
  233. // requested alerting policy. Stackdriver Monitoring creates the
  234. // condition identifiers and includes them in the new policy.
  235. //
  236. // When calling the
  237. // [alertPolicies.update][google.monitoring.v3.AlertPolicyService.UpdateAlertPolicy]
  238. // method to update a policy, including a condition `name` causes the
  239. // existing condition to be updated. Conditions without names are added to
  240. // the updated policy. Existing conditions are deleted if they are not
  241. // updated.
  242. //
  243. // Best practice is to preserve `[CONDITION_ID]` if you make only small
  244. // changes, such as those to condition thresholds, durations, or trigger
  245. // values. Otherwise, treat the change as a new condition and let the
  246. // existing condition be deleted.
  247. string name = 12;
  248. // A short name or phrase used to identify the condition in dashboards,
  249. // notifications, and incidents. To avoid confusion, don't use the same
  250. // display name for multiple conditions in the same policy.
  251. string display_name = 6;
  252. // Only one of the following condition types will be specified.
  253. oneof condition {
  254. // A condition that compares a time series against a threshold.
  255. MetricThreshold condition_threshold = 1;
  256. // A condition that checks that a time series continues to
  257. // receive new data points.
  258. MetricAbsence condition_absent = 2;
  259. // A condition that uses the Monitoring Query Language to define
  260. // alerts.
  261. MonitoringQueryLanguageCondition condition_monitoring_query_language = 19;
  262. }
  263. }
  264. // Operators for combining conditions.
  265. enum ConditionCombinerType {
  266. // An unspecified combiner.
  267. COMBINE_UNSPECIFIED = 0;
  268. // Combine conditions using the logical `AND` operator. An
  269. // incident is created only if all the conditions are met
  270. // simultaneously. This combiner is satisfied if all conditions are
  271. // met, even if they are met on completely different resources.
  272. AND = 1;
  273. // Combine conditions using the logical `OR` operator. An incident
  274. // is created if any of the listed conditions is met.
  275. OR = 2;
  276. // Combine conditions using logical `AND` operator, but unlike the regular
  277. // `AND` option, an incident is created only if all conditions are met
  278. // simultaneously on at least one resource.
  279. AND_WITH_MATCHING_RESOURCE = 3;
  280. }
  281. // Required if the policy exists. The resource name for this policy. The
  282. // format is:
  283. //
  284. // projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID]
  285. //
  286. // `[ALERT_POLICY_ID]` is assigned by Stackdriver Monitoring when the policy
  287. // is created. When calling the
  288. // [alertPolicies.create][google.monitoring.v3.AlertPolicyService.CreateAlertPolicy]
  289. // method, do not include the `name` field in the alerting policy passed as
  290. // part of the request.
  291. string name = 1;
  292. // A short name or phrase used to identify the policy in dashboards,
  293. // notifications, and incidents. To avoid confusion, don't use the same
  294. // display name for multiple policies in the same project. The name is
  295. // limited to 512 Unicode characters.
  296. string display_name = 2;
  297. // Documentation that is included with notifications and incidents related to
  298. // this policy. Best practice is for the documentation to include information
  299. // to help responders understand, mitigate, escalate, and correct the
  300. // underlying problems detected by the alerting policy. Notification channels
  301. // that have limited capacity might not show this documentation.
  302. Documentation documentation = 13;
  303. // User-supplied key/value data to be used for organizing and
  304. // identifying the `AlertPolicy` objects.
  305. //
  306. // The field can contain up to 64 entries. Each key and value is limited to
  307. // 63 Unicode characters or 128 bytes, whichever is smaller. Labels and
  308. // values can contain only lowercase letters, numerals, underscores, and
  309. // dashes. Keys must begin with a letter.
  310. map<string, string> user_labels = 16;
  311. // A list of conditions for the policy. The conditions are combined by AND or
  312. // OR according to the `combiner` field. If the combined conditions evaluate
  313. // to true, then an incident is created. A policy can have from one to six
  314. // conditions.
  315. // If `condition_time_series_query_language` is present, it must be the only
  316. // `condition`.
  317. repeated Condition conditions = 12;
  318. // How to combine the results of multiple conditions to determine if an
  319. // incident should be opened.
  320. // If `condition_time_series_query_language` is present, this must be
  321. // `COMBINE_UNSPECIFIED`.
  322. ConditionCombinerType combiner = 6;
  323. // Whether or not the policy is enabled. On write, the default interpretation
  324. // if unset is that the policy is enabled. On read, clients should not make
  325. // any assumption about the state if it has not been populated. The
  326. // field should always be populated on List and Get operations, unless
  327. // a field projection has been specified that strips it out.
  328. google.protobuf.BoolValue enabled = 17;
  329. // Read-only description of how the alert policy is invalid. OK if the alert
  330. // policy is valid. If not OK, the alert policy will not generate incidents.
  331. google.rpc.Status validity = 18;
  332. // Identifies the notification channels to which notifications should be sent
  333. // when incidents are opened or closed or when new violations occur on
  334. // an already opened incident. Each element of this array corresponds to
  335. // the `name` field in each of the
  336. // [`NotificationChannel`][google.monitoring.v3.NotificationChannel]
  337. // objects that are returned from the [`ListNotificationChannels`]
  338. // [google.monitoring.v3.NotificationChannelService.ListNotificationChannels]
  339. // method. The format of the entries in this field is:
  340. //
  341. // projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID]
  342. repeated string notification_channels = 14;
  343. // A read-only record of the creation of the alerting policy. If provided
  344. // in a call to create or update, this field will be ignored.
  345. MutationRecord creation_record = 10;
  346. // A read-only record of the most recent change to the alerting policy. If
  347. // provided in a call to create or update, this field will be ignored.
  348. MutationRecord mutation_record = 11;
  349. }