logging_metrics.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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.logging.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/distribution.proto";
  19. import "google/api/field_behavior.proto";
  20. import "google/api/metric.proto";
  21. import "google/api/resource.proto";
  22. import "google/protobuf/empty.proto";
  23. import "google/protobuf/timestamp.proto";
  24. option cc_enable_arenas = true;
  25. option csharp_namespace = "Google.Cloud.Logging.V2";
  26. option go_package = "google.golang.org/genproto/googleapis/logging/v2;logging";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "LoggingMetricsProto";
  29. option java_package = "com.google.logging.v2";
  30. option php_namespace = "Google\\Cloud\\Logging\\V2";
  31. option ruby_package = "Google::Cloud::Logging::V2";
  32. // Service for configuring logs-based metrics.
  33. service MetricsServiceV2 {
  34. option (google.api.default_host) = "logging.googleapis.com";
  35. option (google.api.oauth_scopes) =
  36. "https://www.googleapis.com/auth/cloud-platform,"
  37. "https://www.googleapis.com/auth/cloud-platform.read-only,"
  38. "https://www.googleapis.com/auth/logging.admin,"
  39. "https://www.googleapis.com/auth/logging.read,"
  40. "https://www.googleapis.com/auth/logging.write";
  41. // Lists logs-based metrics.
  42. rpc ListLogMetrics(ListLogMetricsRequest) returns (ListLogMetricsResponse) {
  43. option (google.api.http) = {
  44. get: "/v2/{parent=projects/*}/metrics"
  45. };
  46. option (google.api.method_signature) = "parent";
  47. }
  48. // Gets a logs-based metric.
  49. rpc GetLogMetric(GetLogMetricRequest) returns (LogMetric) {
  50. option (google.api.http) = {
  51. get: "/v2/{metric_name=projects/*/metrics/*}"
  52. };
  53. option (google.api.method_signature) = "metric_name";
  54. }
  55. // Creates a logs-based metric.
  56. rpc CreateLogMetric(CreateLogMetricRequest) returns (LogMetric) {
  57. option (google.api.http) = {
  58. post: "/v2/{parent=projects/*}/metrics"
  59. body: "metric"
  60. };
  61. option (google.api.method_signature) = "parent,metric";
  62. }
  63. // Creates or updates a logs-based metric.
  64. rpc UpdateLogMetric(UpdateLogMetricRequest) returns (LogMetric) {
  65. option (google.api.http) = {
  66. put: "/v2/{metric_name=projects/*/metrics/*}"
  67. body: "metric"
  68. };
  69. option (google.api.method_signature) = "metric_name,metric";
  70. }
  71. // Deletes a logs-based metric.
  72. rpc DeleteLogMetric(DeleteLogMetricRequest) returns (google.protobuf.Empty) {
  73. option (google.api.http) = {
  74. delete: "/v2/{metric_name=projects/*/metrics/*}"
  75. };
  76. option (google.api.method_signature) = "metric_name";
  77. }
  78. }
  79. // Describes a logs-based metric. The value of the metric is the number of log
  80. // entries that match a logs filter in a given time interval.
  81. //
  82. // Logs-based metrics can also be used to extract values from logs and create a
  83. // distribution of the values. The distribution records the statistics of the
  84. // extracted values along with an optional histogram of the values as specified
  85. // by the bucket options.
  86. message LogMetric {
  87. option (google.api.resource) = {
  88. type: "logging.googleapis.com/LogMetric"
  89. pattern: "projects/{project}/metrics/{metric}"
  90. };
  91. // Logging API version.
  92. enum ApiVersion {
  93. // Logging API v2.
  94. V2 = 0;
  95. // Logging API v1.
  96. V1 = 1;
  97. }
  98. // Required. The client-assigned metric identifier.
  99. // Examples: `"error_count"`, `"nginx/requests"`.
  100. //
  101. // Metric identifiers are limited to 100 characters and can include only the
  102. // following characters: `A-Z`, `a-z`, `0-9`, and the special characters
  103. // `_-.,+!*',()%/`. The forward-slash character (`/`) denotes a hierarchy of
  104. // name pieces, and it cannot be the first character of the name.
  105. //
  106. // This field is the `[METRIC_ID]` part of a metric resource name in the
  107. // format "projects/[PROJECT_ID]/metrics/[METRIC_ID]". Example: If the
  108. // resource name of a metric is
  109. // `"projects/my-project/metrics/nginx%2Frequests"`, this field's value is
  110. // `"nginx/requests"`.
  111. string name = 1 [(google.api.field_behavior) = REQUIRED];
  112. // Optional. A description of this metric, which is used in documentation.
  113. // The maximum length of the description is 8000 characters.
  114. string description = 2 [(google.api.field_behavior) = OPTIONAL];
  115. // Required. An [advanced logs
  116. // filter](https://cloud.google.com/logging/docs/view/advanced_filters) which
  117. // is used to match log entries. Example:
  118. //
  119. // "resource.type=gae_app AND severity>=ERROR"
  120. //
  121. // The maximum length of the filter is 20000 characters.
  122. string filter = 3 [(google.api.field_behavior) = REQUIRED];
  123. // Optional. If set to True, then this metric is disabled and it does not
  124. // generate any points.
  125. bool disabled = 12 [(google.api.field_behavior) = OPTIONAL];
  126. // Optional. The metric descriptor associated with the logs-based metric.
  127. // If unspecified, it uses a default metric descriptor with a DELTA metric
  128. // kind, INT64 value type, with no labels and a unit of "1". Such a metric
  129. // counts the number of log entries matching the `filter` expression.
  130. //
  131. // The `name`, `type`, and `description` fields in the `metric_descriptor`
  132. // are output only, and is constructed using the `name` and `description`
  133. // field in the LogMetric.
  134. //
  135. // To create a logs-based metric that records a distribution of log values, a
  136. // DELTA metric kind with a DISTRIBUTION value type must be used along with
  137. // a `value_extractor` expression in the LogMetric.
  138. //
  139. // Each label in the metric descriptor must have a matching label
  140. // name as the key and an extractor expression as the value in the
  141. // `label_extractors` map.
  142. //
  143. // The `metric_kind` and `value_type` fields in the `metric_descriptor` cannot
  144. // be updated once initially configured. New labels can be added in the
  145. // `metric_descriptor`, but existing labels cannot be modified except for
  146. // their description.
  147. google.api.MetricDescriptor metric_descriptor = 5 [(google.api.field_behavior) = OPTIONAL];
  148. // Optional. A `value_extractor` is required when using a distribution
  149. // logs-based metric to extract the values to record from a log entry.
  150. // Two functions are supported for value extraction: `EXTRACT(field)` or
  151. // `REGEXP_EXTRACT(field, regex)`. The argument are:
  152. // 1. field: The name of the log entry field from which the value is to be
  153. // extracted.
  154. // 2. regex: A regular expression using the Google RE2 syntax
  155. // (https://github.com/google/re2/wiki/Syntax) with a single capture
  156. // group to extract data from the specified log entry field. The value
  157. // of the field is converted to a string before applying the regex.
  158. // It is an error to specify a regex that does not include exactly one
  159. // capture group.
  160. //
  161. // The result of the extraction must be convertible to a double type, as the
  162. // distribution always records double values. If either the extraction or
  163. // the conversion to double fails, then those values are not recorded in the
  164. // distribution.
  165. //
  166. // Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")`
  167. string value_extractor = 6 [(google.api.field_behavior) = OPTIONAL];
  168. // Optional. A map from a label key string to an extractor expression which is
  169. // used to extract data from a log entry field and assign as the label value.
  170. // Each label key specified in the LabelDescriptor must have an associated
  171. // extractor expression in this map. The syntax of the extractor expression
  172. // is the same as for the `value_extractor` field.
  173. //
  174. // The extracted value is converted to the type defined in the label
  175. // descriptor. If the either the extraction or the type conversion fails,
  176. // the label will have a default value. The default value for a string
  177. // label is an empty string, for an integer label its 0, and for a boolean
  178. // label its `false`.
  179. //
  180. // Note that there are upper bounds on the maximum number of labels and the
  181. // number of active time series that are allowed in a project.
  182. map<string, string> label_extractors = 7 [(google.api.field_behavior) = OPTIONAL];
  183. // Optional. The `bucket_options` are required when the logs-based metric is
  184. // using a DISTRIBUTION value type and it describes the bucket boundaries
  185. // used to create a histogram of the extracted values.
  186. google.api.Distribution.BucketOptions bucket_options = 8 [(google.api.field_behavior) = OPTIONAL];
  187. // Output only. The creation timestamp of the metric.
  188. //
  189. // This field may not be present for older metrics.
  190. google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  191. // Output only. The last update timestamp of the metric.
  192. //
  193. // This field may not be present for older metrics.
  194. google.protobuf.Timestamp update_time = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  195. // Deprecated. The API version that created or updated this metric.
  196. // The v2 format is used by default and cannot be changed.
  197. ApiVersion version = 4 [deprecated = true];
  198. }
  199. // The parameters to ListLogMetrics.
  200. message ListLogMetricsRequest {
  201. // Required. The name of the project containing the metrics:
  202. //
  203. // "projects/[PROJECT_ID]"
  204. string parent = 1 [
  205. (google.api.field_behavior) = REQUIRED,
  206. (google.api.resource_reference) = {
  207. type: "cloudresourcemanager.googleapis.com/Project"
  208. }
  209. ];
  210. // Optional. If present, then retrieve the next batch of results from the
  211. // preceding call to this method. `pageToken` must be the value of
  212. // `nextPageToken` from the previous response. The values of other method
  213. // parameters should be identical to those in the previous call.
  214. string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
  215. // Optional. The maximum number of results to return from this request.
  216. // Non-positive values are ignored. The presence of `nextPageToken` in the
  217. // response indicates that more results might be available.
  218. int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL];
  219. }
  220. // Result returned from ListLogMetrics.
  221. message ListLogMetricsResponse {
  222. // A list of logs-based metrics.
  223. repeated LogMetric metrics = 1;
  224. // If there might be more results than appear in this response, then
  225. // `nextPageToken` is included. To get the next set of results, call this
  226. // method again using the value of `nextPageToken` as `pageToken`.
  227. string next_page_token = 2;
  228. }
  229. // The parameters to GetLogMetric.
  230. message GetLogMetricRequest {
  231. // Required. The resource name of the desired metric:
  232. //
  233. // "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
  234. string metric_name = 1 [
  235. (google.api.field_behavior) = REQUIRED,
  236. (google.api.resource_reference) = {
  237. type: "logging.googleapis.com/LogMetric"
  238. }
  239. ];
  240. }
  241. // The parameters to CreateLogMetric.
  242. message CreateLogMetricRequest {
  243. // Required. The resource name of the project in which to create the metric:
  244. //
  245. // "projects/[PROJECT_ID]"
  246. //
  247. // The new metric must be provided in the request.
  248. string parent = 1 [
  249. (google.api.field_behavior) = REQUIRED,
  250. (google.api.resource_reference) = {
  251. child_type: "logging.googleapis.com/LogMetric"
  252. }
  253. ];
  254. // Required. The new logs-based metric, which must not have an identifier that
  255. // already exists.
  256. LogMetric metric = 2 [(google.api.field_behavior) = REQUIRED];
  257. }
  258. // The parameters to UpdateLogMetric.
  259. message UpdateLogMetricRequest {
  260. // Required. The resource name of the metric to update:
  261. //
  262. // "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
  263. //
  264. // The updated metric must be provided in the request and it's
  265. // `name` field must be the same as `[METRIC_ID]` If the metric
  266. // does not exist in `[PROJECT_ID]`, then a new metric is created.
  267. string metric_name = 1 [
  268. (google.api.field_behavior) = REQUIRED,
  269. (google.api.resource_reference) = {
  270. type: "logging.googleapis.com/LogMetric"
  271. }
  272. ];
  273. // Required. The updated metric.
  274. LogMetric metric = 2 [(google.api.field_behavior) = REQUIRED];
  275. }
  276. // The parameters to DeleteLogMetric.
  277. message DeleteLogMetricRequest {
  278. // Required. The resource name of the metric to delete:
  279. //
  280. // "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
  281. string metric_name = 1 [
  282. (google.api.field_behavior) = REQUIRED,
  283. (google.api.resource_reference) = {
  284. type: "logging.googleapis.com/LogMetric"
  285. }
  286. ];
  287. }