metric.proto 11 KB

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