metric.proto 10 KB

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