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/field_behavior.proto"; 22import "google/api/monitored_resource.proto"; 23import "google/api/resource.proto"; 24import "google/logging/v2/log_entry.proto"; 25import "google/protobuf/duration.proto"; 26import "google/protobuf/empty.proto"; 27import "google/rpc/status.proto"; 28 29option cc_enable_arenas = true; 30option csharp_namespace = "Google.Cloud.Logging.V2"; 31option go_package = "cloud.google.com/go/logging/apiv2/loggingpb;loggingpb"; 32option java_multiple_files = true; 33option java_outer_classname = "LoggingProto"; 34option java_package = "com.google.logging.v2"; 35option php_namespace = "Google\\Cloud\\Logging\\V2"; 36option ruby_package = "Google::Cloud::Logging::V2"; 37 38// Service for ingesting and querying logs. 39service LoggingServiceV2 { 40 option (google.api.default_host) = "logging.googleapis.com"; 41 option (google.api.oauth_scopes) = 42 "https://www.googleapis.com/auth/cloud-platform," 43 "https://www.googleapis.com/auth/cloud-platform.read-only," 44 "https://www.googleapis.com/auth/logging.admin," 45 "https://www.googleapis.com/auth/logging.read," 46 "https://www.googleapis.com/auth/logging.write"; 47 48 // Deletes all the log entries in a log for the _Default Log Bucket. The log 49 // reappears if it receives new entries. Log entries written shortly before 50 // the delete operation might not be deleted. Entries received after the 51 // delete operation with a timestamp before the operation will be deleted. 52 rpc DeleteLog(DeleteLogRequest) returns (google.protobuf.Empty) { 53 option (google.api.http) = { 54 delete: "/v2/{log_name=projects/*/logs/*}" 55 additional_bindings { delete: "/v2/{log_name=*/*/logs/*}" } 56 additional_bindings { delete: "/v2/{log_name=organizations/*/logs/*}" } 57 additional_bindings { delete: "/v2/{log_name=folders/*/logs/*}" } 58 additional_bindings { delete: "/v2/{log_name=billingAccounts/*/logs/*}" } 59 }; 60 option (google.api.method_signature) = "log_name"; 61 } 62 63 // Writes log entries to Logging. This API method is the 64 // only way to send log entries to Logging. This method 65 // is used, directly or indirectly, by the Logging agent 66 // (fluentd) and all logging libraries configured to use Logging. 67 // A single request may contain log entries for a maximum of 1000 68 // different resources (projects, organizations, billing accounts or 69 // folders) 70 rpc WriteLogEntries(WriteLogEntriesRequest) 71 returns (WriteLogEntriesResponse) { 72 option (google.api.http) = { 73 post: "/v2/entries:write" 74 body: "*" 75 }; 76 option (google.api.method_signature) = "log_name,resource,labels,entries"; 77 } 78 79 // Lists log entries. Use this method to retrieve log entries that originated 80 // from a project/folder/organization/billing account. For ways to export log 81 // entries, see [Exporting 82 // Logs](https://cloud.google.com/logging/docs/export). 83 rpc ListLogEntries(ListLogEntriesRequest) returns (ListLogEntriesResponse) { 84 option (google.api.http) = { 85 post: "/v2/entries:list" 86 body: "*" 87 }; 88 option (google.api.method_signature) = "resource_names,filter,order_by"; 89 } 90 91 // Lists the descriptors for monitored resource types used by Logging. 92 rpc ListMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest) 93 returns (ListMonitoredResourceDescriptorsResponse) { 94 option (google.api.http) = { 95 get: "/v2/monitoredResourceDescriptors" 96 }; 97 } 98 99 // Lists the logs in projects, organizations, folders, or billing accounts. 100 // Only logs that have entries are listed. 101 rpc ListLogs(ListLogsRequest) returns (ListLogsResponse) { 102 option (google.api.http) = { 103 get: "/v2/{parent=*/*}/logs" 104 additional_bindings { get: "/v2/{parent=projects/*}/logs" } 105 additional_bindings { get: "/v2/{parent=organizations/*}/logs" } 106 additional_bindings { get: "/v2/{parent=folders/*}/logs" } 107 additional_bindings { get: "/v2/{parent=billingAccounts/*}/logs" } 108 additional_bindings { 109 get: "/v2/{parent=projects/*/locations/*/buckets/*/views/*}/logs" 110 } 111 additional_bindings { 112 get: "/v2/{parent=organizations/*/locations/*/buckets/*/views/*}/logs" 113 } 114 additional_bindings { 115 get: "/v2/{parent=folders/*/locations/*/buckets/*/views/*}/logs" 116 } 117 additional_bindings { 118 get: "/v2/{parent=billingAccounts/*/locations/*/buckets/*/views/*}/logs" 119 } 120 }; 121 option (google.api.method_signature) = "parent"; 122 } 123 124 // Streaming read of log entries as they are ingested. Until the stream is 125 // terminated, it will continue reading logs. 126 rpc TailLogEntries(stream TailLogEntriesRequest) 127 returns (stream TailLogEntriesResponse) { 128 option (google.api.http) = { 129 post: "/v2/entries:tail" 130 body: "*" 131 }; 132 } 133} 134 135// The parameters to DeleteLog. 136message DeleteLogRequest { 137 // Required. The resource name of the log to delete: 138 // 139 // * `projects/[PROJECT_ID]/logs/[LOG_ID]` 140 // * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` 141 // * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` 142 // * `folders/[FOLDER_ID]/logs/[LOG_ID]` 143 // 144 // `[LOG_ID]` must be URL-encoded. For example, 145 // `"projects/my-project-id/logs/syslog"`, 146 // `"organizations/123/logs/cloudaudit.googleapis.com%2Factivity"`. 147 // 148 // For more information about log names, see 149 // [LogEntry][google.logging.v2.LogEntry]. 150 string log_name = 1 [ 151 (google.api.field_behavior) = REQUIRED, 152 (google.api.resource_reference) = { type: "logging.googleapis.com/Log" } 153 ]; 154} 155 156// The parameters to WriteLogEntries. 157message WriteLogEntriesRequest { 158 // Optional. A default log resource name that is assigned to all log entries 159 // in `entries` that do not specify a value for `log_name`: 160 // 161 // * `projects/[PROJECT_ID]/logs/[LOG_ID]` 162 // * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` 163 // * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` 164 // * `folders/[FOLDER_ID]/logs/[LOG_ID]` 165 // 166 // `[LOG_ID]` must be URL-encoded. For example: 167 // 168 // "projects/my-project-id/logs/syslog" 169 // "organizations/123/logs/cloudaudit.googleapis.com%2Factivity" 170 // 171 // The permission `logging.logEntries.create` is needed on each project, 172 // organization, billing account, or folder that is receiving new log 173 // entries, whether the resource is specified in `logName` or in an 174 // individual log entry. 175 string log_name = 1 [ 176 (google.api.field_behavior) = OPTIONAL, 177 (google.api.resource_reference) = { type: "logging.googleapis.com/Log" } 178 ]; 179 180 // Optional. A default monitored resource object that is assigned to all log 181 // entries in `entries` that do not specify a value for `resource`. Example: 182 // 183 // { "type": "gce_instance", 184 // "labels": { 185 // "zone": "us-central1-a", "instance_id": "00000000000000000000" }} 186 // 187 // See [LogEntry][google.logging.v2.LogEntry]. 188 google.api.MonitoredResource resource = 2 189 [(google.api.field_behavior) = OPTIONAL]; 190 191 // Optional. Default labels that are added to the `labels` field of all log 192 // entries in `entries`. If a log entry already has a label with the same key 193 // as a label in this parameter, then the log entry's label is not changed. 194 // See [LogEntry][google.logging.v2.LogEntry]. 195 map<string, string> labels = 3 [(google.api.field_behavior) = OPTIONAL]; 196 197 // Required. The log entries to send to Logging. The order of log 198 // entries in this list does not matter. Values supplied in this method's 199 // `log_name`, `resource`, and `labels` fields are copied into those log 200 // entries in this list that do not include values for their corresponding 201 // fields. For more information, see the 202 // [LogEntry][google.logging.v2.LogEntry] type. 203 // 204 // If the `timestamp` or `insert_id` fields are missing in log entries, then 205 // this method supplies the current time or a unique identifier, respectively. 206 // The supplied values are chosen so that, among the log entries that did not 207 // supply their own values, the entries earlier in the list will sort before 208 // the entries later in the list. See the `entries.list` method. 209 // 210 // Log entries with timestamps that are more than the 211 // [logs retention period](https://cloud.google.com/logging/quotas) in 212 // the past or more than 24 hours in the future will not be available when 213 // calling `entries.list`. However, those log entries can still be [exported 214 // with 215 // LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). 216 // 217 // To improve throughput and to avoid exceeding the 218 // [quota limit](https://cloud.google.com/logging/quotas) for calls to 219 // `entries.write`, you should try to include several log entries in this 220 // list, rather than calling this method for each individual log entry. 221 repeated LogEntry entries = 4 [(google.api.field_behavior) = REQUIRED]; 222 223 // Optional. Whether a batch's valid entries should be written even if some 224 // other entry failed due to a permanent error such as INVALID_ARGUMENT or 225 // PERMISSION_DENIED. If any entry failed, then the response status is the 226 // response status of one of the failed entries. The response will include 227 // error details in `WriteLogEntriesPartialErrors.log_entry_errors` keyed by 228 // the entries' zero-based index in the `entries`. Failed requests for which 229 // no entries are written will not include per-entry errors. 230 bool partial_success = 5 [(google.api.field_behavior) = OPTIONAL]; 231 232 // Optional. If true, the request should expect normal response, but the 233 // entries won't be persisted nor exported. Useful for checking whether the 234 // logging API endpoints are working properly before sending valuable data. 235 bool dry_run = 6 [(google.api.field_behavior) = OPTIONAL]; 236} 237 238// Result returned from WriteLogEntries. 239message WriteLogEntriesResponse {} 240 241// Error details for WriteLogEntries with partial success. 242message WriteLogEntriesPartialErrors { 243 // When `WriteLogEntriesRequest.partial_success` is true, records the error 244 // status for entries that were not written due to a permanent error, keyed 245 // by the entry's zero-based index in `WriteLogEntriesRequest.entries`. 246 // 247 // Failed requests for which no entries are written will not include 248 // per-entry errors. 249 map<int32, google.rpc.Status> log_entry_errors = 1; 250} 251 252// The parameters to `ListLogEntries`. 253message ListLogEntriesRequest { 254 // Required. Names of one or more parent resources from which to 255 // retrieve log entries: 256 // 257 // * `projects/[PROJECT_ID]` 258 // * `organizations/[ORGANIZATION_ID]` 259 // * `billingAccounts/[BILLING_ACCOUNT_ID]` 260 // * `folders/[FOLDER_ID]` 261 // 262 // May alternatively be one or more views: 263 // 264 // * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 265 // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 266 // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 267 // * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 268 // 269 // Projects listed in the `project_ids` field are added to this list. 270 // A maximum of 100 resources may be specified in a single request. 271 repeated string resource_names = 8 [ 272 (google.api.field_behavior) = REQUIRED, 273 (google.api.resource_reference) = { 274 child_type: "logging.googleapis.com/Log" 275 } 276 ]; 277 278 // Optional. Only log entries that match the filter are returned. An empty 279 // filter matches all log entries in the resources listed in `resource_names`. 280 // Referencing a parent resource that is not listed in `resource_names` will 281 // cause the filter to return no results. The maximum length of a filter is 282 // 20,000 characters. 283 string filter = 2 [(google.api.field_behavior) = OPTIONAL]; 284 285 // Optional. How the results should be sorted. Presently, the only permitted 286 // values are `"timestamp asc"` (default) and `"timestamp desc"`. The first 287 // option returns entries in order of increasing values of 288 // `LogEntry.timestamp` (oldest first), and the second option returns entries 289 // in order of decreasing timestamps (newest first). Entries with equal 290 // timestamps are returned in order of their `insert_id` values. 291 string order_by = 3 [(google.api.field_behavior) = OPTIONAL]; 292 293 // Optional. The maximum number of results to return from this request. 294 // Default is 50. If the value is negative or exceeds 1000, the request is 295 // rejected. The presence of `next_page_token` in the response indicates that 296 // more results might be available. 297 int32 page_size = 4 [(google.api.field_behavior) = OPTIONAL]; 298 299 // Optional. If present, then retrieve the next batch of results from the 300 // preceding call to this method. `page_token` must be the value of 301 // `next_page_token` from the previous response. The values of other method 302 // parameters should be identical to those in the previous call. 303 string page_token = 5 [(google.api.field_behavior) = OPTIONAL]; 304} 305 306// Result returned from `ListLogEntries`. 307message ListLogEntriesResponse { 308 // A list of log entries. If `entries` is empty, `nextPageToken` may still be 309 // returned, indicating that more entries may exist. See `nextPageToken` for 310 // more information. 311 repeated LogEntry entries = 1; 312 313 // If there might be more results than those appearing in this response, then 314 // `nextPageToken` is included. To get the next set of results, call this 315 // method again using the value of `nextPageToken` as `pageToken`. 316 // 317 // If a value for `next_page_token` appears and the `entries` field is empty, 318 // it means that the search found no log entries so far but it did not have 319 // time to search all the possible log entries. Retry the method with this 320 // value for `page_token` to continue the search. Alternatively, consider 321 // speeding up the search by changing your filter to specify a single log name 322 // or resource type, or to narrow the time range of the search. 323 string next_page_token = 2; 324} 325 326// The parameters to ListMonitoredResourceDescriptors 327message ListMonitoredResourceDescriptorsRequest { 328 // Optional. The maximum number of results to return from this request. 329 // Non-positive values are ignored. The presence of `nextPageToken` in the 330 // response indicates that more results might be available. 331 int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; 332 333 // Optional. If present, then retrieve the next batch of results from the 334 // preceding call to this method. `pageToken` must be the value of 335 // `nextPageToken` from the previous response. The values of other method 336 // parameters should be identical to those in the previous call. 337 string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; 338} 339 340// Result returned from ListMonitoredResourceDescriptors. 341message ListMonitoredResourceDescriptorsResponse { 342 // A list of resource descriptors. 343 repeated google.api.MonitoredResourceDescriptor resource_descriptors = 1; 344 345 // If there might be more results than those appearing in this response, then 346 // `nextPageToken` is included. To get the next set of results, call this 347 // method again using the value of `nextPageToken` as `pageToken`. 348 string next_page_token = 2; 349} 350 351// The parameters to ListLogs. 352message ListLogsRequest { 353 // Required. The resource name to list logs for: 354 // 355 // * `projects/[PROJECT_ID]` 356 // * `organizations/[ORGANIZATION_ID]` 357 // * `billingAccounts/[BILLING_ACCOUNT_ID]` 358 // * `folders/[FOLDER_ID]` 359 string parent = 1 [ 360 (google.api.field_behavior) = REQUIRED, 361 (google.api.resource_reference) = { 362 child_type: "logging.googleapis.com/Log" 363 } 364 ]; 365 366 // Optional. List of resource names to list logs for: 367 // 368 // * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 369 // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 370 // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 371 // * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 372 // 373 // To support legacy queries, it could also be: 374 // 375 // * `projects/[PROJECT_ID]` 376 // * `organizations/[ORGANIZATION_ID]` 377 // * `billingAccounts/[BILLING_ACCOUNT_ID]` 378 // * `folders/[FOLDER_ID]` 379 // 380 // The resource name in the `parent` field is added to this list. 381 repeated string resource_names = 8 [ 382 (google.api.field_behavior) = OPTIONAL, 383 (google.api.resource_reference) = { 384 child_type: "logging.googleapis.com/Log" 385 } 386 ]; 387 388 // Optional. The maximum number of results to return from this request. 389 // Non-positive values are ignored. The presence of `nextPageToken` in the 390 // response indicates that more results might be available. 391 int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; 392 393 // Optional. If present, then retrieve the next batch of results from the 394 // preceding call to this method. `pageToken` must be the value of 395 // `nextPageToken` from the previous response. The values of other method 396 // parameters should be identical to those in the previous call. 397 string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; 398} 399 400// Result returned from ListLogs. 401message ListLogsResponse { 402 // A list of log names. For example, 403 // `"projects/my-project/logs/syslog"` or 404 // `"organizations/123/logs/cloudresourcemanager.googleapis.com%2Factivity"`. 405 repeated string log_names = 3; 406 407 // If there might be more results than those appearing in this response, then 408 // `nextPageToken` is included. To get the next set of results, call this 409 // method again using the value of `nextPageToken` as `pageToken`. 410 string next_page_token = 2; 411} 412 413// The parameters to `TailLogEntries`. 414message TailLogEntriesRequest { 415 // Required. Name of a parent resource from which to retrieve log entries: 416 // 417 // * `projects/[PROJECT_ID]` 418 // * `organizations/[ORGANIZATION_ID]` 419 // * `billingAccounts/[BILLING_ACCOUNT_ID]` 420 // * `folders/[FOLDER_ID]` 421 // 422 // May alternatively be one or more views: 423 // 424 // * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 425 // * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 426 // * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 427 // * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 428 repeated string resource_names = 1 [(google.api.field_behavior) = REQUIRED]; 429 430 // Optional. Only log entries that match the filter are returned. An empty 431 // filter matches all log entries in the resources listed in `resource_names`. 432 // Referencing a parent resource that is not listed in `resource_names` will 433 // cause the filter to return no results. The maximum length of a filter is 434 // 20,000 characters. 435 string filter = 2 [(google.api.field_behavior) = OPTIONAL]; 436 437 // Optional. The amount of time to buffer log entries at the server before 438 // being returned to prevent out of order results due to late arriving log 439 // entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 440 // milliseconds. 441 google.protobuf.Duration buffer_window = 3 442 [(google.api.field_behavior) = OPTIONAL]; 443} 444 445// Result returned from `TailLogEntries`. 446message TailLogEntriesResponse { 447 // Information about entries that were omitted from the session. 448 message SuppressionInfo { 449 // An indicator of why entries were omitted. 450 enum Reason { 451 // Unexpected default. 452 REASON_UNSPECIFIED = 0; 453 454 // Indicates suppression occurred due to relevant entries being 455 // received in excess of rate limits. For quotas and limits, see 456 // [Logging API quotas and 457 // limits](https://cloud.google.com/logging/quotas#api-limits). 458 RATE_LIMIT = 1; 459 460 // Indicates suppression occurred due to the client not consuming 461 // responses quickly enough. 462 NOT_CONSUMED = 2; 463 } 464 465 // The reason that entries were omitted from the session. 466 Reason reason = 1; 467 468 // A lower bound on the count of entries omitted due to `reason`. 469 int32 suppressed_count = 2; 470 } 471 472 // A list of log entries. Each response in the stream will order entries with 473 // increasing values of `LogEntry.timestamp`. Ordering is not guaranteed 474 // between separate responses. 475 repeated LogEntry entries = 1; 476 477 // If entries that otherwise would have been included in the session were not 478 // sent back to the client, counts of relevant entries omitted from the 479 // session with the reason that they were not included. There will be at most 480 // one of each reason per response. The counts represent the number of 481 // suppressed entries since the last streamed response. 482 repeated SuppressionInfo suppression_info = 2; 483} 484