Skip to content

Commit e8857c4

Browse files
Google APIscopybara-github
authored andcommitted
feat: add the Tailing API to get a live stream of the tail end of filtered logs
PiperOrigin-RevId: 344435830
1 parent ebdbe9a commit e8857c4

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

google/logging/v2/logging.proto

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ service LoggingServiceV2 {
125125
};
126126
option (google.api.method_signature) = "parent";
127127
}
128+
129+
// Streaming read of log entries as they are ingested. Until the stream is
130+
// terminated, it will continue reading logs.
131+
rpc TailLogEntries(stream TailLogEntriesRequest) returns (stream TailLogEntriesResponse) {
132+
option (google.api.http) = {
133+
post: "/v2/entries:tail"
134+
body: "*"
135+
};
136+
}
128137
}
129138

130139
// The parameters to DeleteLog.
@@ -254,6 +263,11 @@ message ListLogEntriesRequest {
254263
// "billingAccounts/[BILLING_ACCOUNT_ID]"
255264
// "folders/[FOLDER_ID]"
256265
//
266+
// May alternatively be one or more views
267+
// projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
268+
// organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
269+
// billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
270+
// folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
257271
//
258272
// Projects listed in the `project_ids` field are added to this list.
259273
repeated string resource_names = 8 [
@@ -363,6 +377,19 @@ message ListLogsRequest {
363377
// `nextPageToken` from the previous response. The values of other method
364378
// parameters should be identical to those in the previous call.
365379
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
380+
381+
// Optional. The resource name that owns the logs:
382+
// projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
383+
// organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
384+
// billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
385+
// folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
386+
//
387+
// To support legacy queries, it could also be:
388+
// "projects/[PROJECT_ID]"
389+
// "organizations/[ORGANIZATION_ID]"
390+
// "billingAccounts/[BILLING_ACCOUNT_ID]"
391+
// "folders/[FOLDER_ID]"
392+
repeated string resource_names = 8 [(google.api.field_behavior) = OPTIONAL];
366393
}
367394

368395
// Result returned from ListLogs.
@@ -377,3 +404,75 @@ message ListLogsResponse {
377404
// method again using the value of `nextPageToken` as `pageToken`.
378405
string next_page_token = 2;
379406
}
407+
408+
// The parameters to `TailLogEntries`.
409+
message TailLogEntriesRequest {
410+
// Required. Name of a parent resource from which to retrieve log entries:
411+
//
412+
// "projects/[PROJECT_ID]"
413+
// "organizations/[ORGANIZATION_ID]"
414+
// "billingAccounts/[BILLING_ACCOUNT_ID]"
415+
// "folders/[FOLDER_ID]"
416+
//
417+
// May alternatively be one or more views:
418+
// "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
419+
// "organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
420+
// "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
421+
// "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
422+
repeated string resource_names = 1 [(google.api.field_behavior) = REQUIRED];
423+
424+
// Optional. A filter that chooses which log entries to return. See [Advanced
425+
// Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
426+
// Only log entries that match the filter are returned. An empty filter
427+
// matches all log entries in the resources listed in `resource_names`.
428+
// Referencing a parent resource that is not in `resource_names` will cause
429+
// the filter to return no results. The maximum length of the filter is 20000
430+
// characters.
431+
string filter = 2 [(google.api.field_behavior) = OPTIONAL];
432+
433+
// Optional. The amount of time to buffer log entries at the server before
434+
// being returned to prevent out of order results due to late arriving log
435+
// entries. Valid values are between 0-60000 milliseconds. Defaults to 2000
436+
// milliseconds.
437+
google.protobuf.Duration buffer_window = 3 [(google.api.field_behavior) = OPTIONAL];
438+
}
439+
440+
// Result returned from `TailLogEntries`.
441+
message TailLogEntriesResponse {
442+
// Information about entries that were omitted from the session.
443+
message SuppressionInfo {
444+
// An indicator of why entries were omitted.
445+
enum Reason {
446+
// Unexpected default.
447+
REASON_UNSPECIFIED = 0;
448+
449+
// Indicates suppression occurred due to relevant entries being
450+
// received in excess of rate limits. For quotas and limits, see
451+
// [Logging API quotas and
452+
// limits](https://cloud.google.com/logging/quotas#api-limits).
453+
RATE_LIMIT = 1;
454+
455+
// Indicates suppression occurred due to the client not consuming
456+
// responses quickly enough.
457+
NOT_CONSUMED = 2;
458+
}
459+
460+
// The reason that entries were omitted from the session.
461+
Reason reason = 1;
462+
463+
// A lower bound on the count of entries omitted due to `reason`.
464+
int32 suppressed_count = 2;
465+
}
466+
467+
// A list of log entries. Each response in the stream will order entries with
468+
// increasing values of `LogEntry.timestamp`. Ordering is not guaranteed
469+
// between separate responses.
470+
repeated LogEntry entries = 1;
471+
472+
// If entries that otherwise would have been included in the session were not
473+
// sent back to the client, counts of relevant entries omitted from the
474+
// session with the reason that they were not included. There will be at most
475+
// one of each reason per response. The counts represent the number of
476+
// suppressed entries since the last streamed response.
477+
repeated SuppressionInfo suppression_info = 2;
478+
}

google/logging/v2/logging.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ backend:
2626
deadline: 60.0
2727
- selector: google.logging.v2.LoggingServiceV2.ListLogEntries
2828
deadline: 10.0
29+
- selector: google.logging.v2.LoggingServiceV2.TailLogEntries
30+
deadline: 3600.0
2931
- selector: 'google.logging.v2.MetricsServiceV2.*'
3032
deadline: 60.0
3133

0 commit comments

Comments
 (0)