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