logging_metrics.proto 13 KB

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