metric.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. // Copyright 2023 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.api;
  16. import "google/api/label.proto";
  17. import "google/api/launch_stage.proto";
  18. import "google/protobuf/duration.proto";
  19. option go_package = "google.golang.org/genproto/googleapis/api/metric;metric";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "MetricProto";
  22. option java_package = "com.google.api";
  23. option objc_class_prefix = "GAPI";
  24. // Defines a metric type and its schema. Once a metric descriptor is created,
  25. // deleting or altering it stops data collection and makes the metric type's
  26. // existing data unusable.
  27. //
  28. message MetricDescriptor {
  29. // The kind of measurement. It describes how the data is reported.
  30. // For information on setting the start time and end time based on
  31. // the MetricKind, see [TimeInterval][google.monitoring.v3.TimeInterval].
  32. enum MetricKind {
  33. // Do not use this default value.
  34. METRIC_KIND_UNSPECIFIED = 0;
  35. // An instantaneous measurement of a value.
  36. GAUGE = 1;
  37. // The change in a value during a time interval.
  38. DELTA = 2;
  39. // A value accumulated over a time interval. Cumulative
  40. // measurements in a time series should have the same start time
  41. // and increasing end times, until an event resets the cumulative
  42. // value to zero and sets a new start time for the following
  43. // points.
  44. CUMULATIVE = 3;
  45. }
  46. // The value type of a metric.
  47. enum ValueType {
  48. // Do not use this default value.
  49. VALUE_TYPE_UNSPECIFIED = 0;
  50. // The value is a boolean.
  51. // This value type can be used only if the metric kind is `GAUGE`.
  52. BOOL = 1;
  53. // The value is a signed 64-bit integer.
  54. INT64 = 2;
  55. // The value is a double precision floating point number.
  56. DOUBLE = 3;
  57. // The value is a text string.
  58. // This value type can be used only if the metric kind is `GAUGE`.
  59. STRING = 4;
  60. // The value is a [`Distribution`][google.api.Distribution].
  61. DISTRIBUTION = 5;
  62. // The value is money.
  63. MONEY = 6;
  64. }
  65. // Additional annotations that can be used to guide the usage of a metric.
  66. message MetricDescriptorMetadata {
  67. // Deprecated. Must use the
  68. // [MetricDescriptor.launch_stage][google.api.MetricDescriptor.launch_stage]
  69. // instead.
  70. LaunchStage launch_stage = 1 [deprecated = true];
  71. // The sampling period of metric data points. For metrics which are written
  72. // periodically, consecutive data points are stored at this time interval,
  73. // excluding data loss due to errors. Metrics with a higher granularity have
  74. // a smaller sampling period.
  75. google.protobuf.Duration sample_period = 2;
  76. // The delay of data points caused by ingestion. Data points older than this
  77. // age are guaranteed to be ingested and available to be read, excluding
  78. // data loss due to errors.
  79. google.protobuf.Duration ingest_delay = 3;
  80. }
  81. // The resource name of the metric descriptor.
  82. string name = 1;
  83. // The metric type, including its DNS name prefix. The type is not
  84. // URL-encoded. All user-defined metric types have the DNS name
  85. // `custom.googleapis.com` or `external.googleapis.com`. Metric types should
  86. // use a natural hierarchical grouping. For example:
  87. //
  88. // "custom.googleapis.com/invoice/paid/amount"
  89. // "external.googleapis.com/prometheus/up"
  90. // "appengine.googleapis.com/http/server/response_latencies"
  91. string type = 8;
  92. // The set of labels that can be used to describe a specific
  93. // instance of this metric type. For example, the
  94. // `appengine.googleapis.com/http/server/response_latencies` metric
  95. // type has a label for the HTTP response code, `response_code`, so
  96. // you can look at latencies for successful responses or just
  97. // for responses that failed.
  98. repeated LabelDescriptor labels = 2;
  99. // Whether the metric records instantaneous values, changes to a value, etc.
  100. // Some combinations of `metric_kind` and `value_type` might not be supported.
  101. MetricKind metric_kind = 3;
  102. // Whether the measurement is an integer, a floating-point number, etc.
  103. // Some combinations of `metric_kind` and `value_type` might not be supported.
  104. ValueType value_type = 4;
  105. // The units in which the metric value is reported. It is only applicable
  106. // if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit`
  107. // defines the representation of the stored metric values.
  108. //
  109. // Different systems might scale the values to be more easily displayed (so a
  110. // value of `0.02kBy` _might_ be displayed as `20By`, and a value of
  111. // `3523kBy` _might_ be displayed as `3.5MBy`). However, if the `unit` is
  112. // `kBy`, then the value of the metric is always in thousands of bytes, no
  113. // matter how it might be displayed.
  114. //
  115. // If you want a custom metric to record the exact number of CPU-seconds used
  116. // by a job, you can create an `INT64 CUMULATIVE` metric whose `unit` is
  117. // `s{CPU}` (or equivalently `1s{CPU}` or just `s`). If the job uses 12,005
  118. // CPU-seconds, then the value is written as `12005`.
  119. //
  120. // Alternatively, if you want a custom metric to record data in a more
  121. // granular way, you can create a `DOUBLE CUMULATIVE` metric whose `unit` is
  122. // `ks{CPU}`, and then write the value `12.005` (which is `12005/1000`),
  123. // or use `Kis{CPU}` and write `11.723` (which is `12005/1024`).
  124. //
  125. // The supported units are a subset of [The Unified Code for Units of
  126. // Measure](https://unitsofmeasure.org/ucum.html) standard:
  127. //
  128. // **Basic units (UNIT)**
  129. //
  130. // * `bit` bit
  131. // * `By` byte
  132. // * `s` second
  133. // * `min` minute
  134. // * `h` hour
  135. // * `d` day
  136. // * `1` dimensionless
  137. //
  138. // **Prefixes (PREFIX)**
  139. //
  140. // * `k` kilo (10^3)
  141. // * `M` mega (10^6)
  142. // * `G` giga (10^9)
  143. // * `T` tera (10^12)
  144. // * `P` peta (10^15)
  145. // * `E` exa (10^18)
  146. // * `Z` zetta (10^21)
  147. // * `Y` yotta (10^24)
  148. //
  149. // * `m` milli (10^-3)
  150. // * `u` micro (10^-6)
  151. // * `n` nano (10^-9)
  152. // * `p` pico (10^-12)
  153. // * `f` femto (10^-15)
  154. // * `a` atto (10^-18)
  155. // * `z` zepto (10^-21)
  156. // * `y` yocto (10^-24)
  157. //
  158. // * `Ki` kibi (2^10)
  159. // * `Mi` mebi (2^20)
  160. // * `Gi` gibi (2^30)
  161. // * `Ti` tebi (2^40)
  162. // * `Pi` pebi (2^50)
  163. //
  164. // **Grammar**
  165. //
  166. // The grammar also includes these connectors:
  167. //
  168. // * `/` division or ratio (as an infix operator). For examples,
  169. // `kBy/{email}` or `MiBy/10ms` (although you should almost never
  170. // have `/s` in a metric `unit`; rates should always be computed at
  171. // query time from the underlying cumulative or delta value).
  172. // * `.` multiplication or composition (as an infix operator). For
  173. // examples, `GBy.d` or `k{watt}.h`.
  174. //
  175. // The grammar for a unit is as follows:
  176. //
  177. // Expression = Component { "." Component } { "/" Component } ;
  178. //
  179. // Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ]
  180. // | Annotation
  181. // | "1"
  182. // ;
  183. //
  184. // Annotation = "{" NAME "}" ;
  185. //
  186. // Notes:
  187. //
  188. // * `Annotation` is just a comment if it follows a `UNIT`. If the annotation
  189. // is used alone, then the unit is equivalent to `1`. For examples,
  190. // `{request}/s == 1/s`, `By{transmitted}/s == By/s`.
  191. // * `NAME` is a sequence of non-blank printable ASCII characters not
  192. // containing `{` or `}`.
  193. // * `1` represents a unitary [dimensionless
  194. // unit](https://en.wikipedia.org/wiki/Dimensionless_quantity) of 1, such
  195. // as in `1/s`. It is typically used when none of the basic units are
  196. // appropriate. For example, "new users per day" can be represented as
  197. // `1/d` or `{new-users}/d` (and a metric value `5` would mean "5 new
  198. // users). Alternatively, "thousands of page views per day" would be
  199. // represented as `1000/d` or `k1/d` or `k{page_views}/d` (and a metric
  200. // value of `5.3` would mean "5300 page views per day").
  201. // * `%` represents dimensionless value of 1/100, and annotates values giving
  202. // a percentage (so the metric values are typically in the range of 0..100,
  203. // and a metric value `3` means "3 percent").
  204. // * `10^2.%` indicates a metric contains a ratio, typically in the range
  205. // 0..1, that will be multiplied by 100 and displayed as a percentage
  206. // (so a metric value `0.03` means "3 percent").
  207. string unit = 5;
  208. // A detailed description of the metric, which can be used in documentation.
  209. string description = 6;
  210. // A concise name for the metric, which can be displayed in user interfaces.
  211. // Use sentence case without an ending period, for example "Request count".
  212. // This field is optional but it is recommended to be set for any metrics
  213. // associated with user-visible concepts, such as Quota.
  214. string display_name = 7;
  215. // Optional. Metadata which can be used to guide usage of the metric.
  216. MetricDescriptorMetadata metadata = 10;
  217. // Optional. The launch stage of the metric definition.
  218. LaunchStage launch_stage = 12;
  219. // Read-only. If present, then a [time
  220. // series][google.monitoring.v3.TimeSeries], which is identified partially by
  221. // a metric type and a
  222. // [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor], that
  223. // is associated with this metric type can only be associated with one of the
  224. // monitored resource types listed here.
  225. repeated string monitored_resource_types = 13;
  226. }
  227. // A specific metric, identified by specifying values for all of the
  228. // labels of a [`MetricDescriptor`][google.api.MetricDescriptor].
  229. message Metric {
  230. // An existing metric type, see
  231. // [google.api.MetricDescriptor][google.api.MetricDescriptor]. For example,
  232. // `custom.googleapis.com/invoice/paid/amount`.
  233. string type = 3;
  234. // The set of label values that uniquely identify this metric. All
  235. // labels listed in the `MetricDescriptor` must be assigned values.
  236. map<string, string> labels = 2;
  237. }