Skip to main content

Read

Read log entries from the specified log group.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const LogLevel_Level = cloudApi.logging.log_entry.LogLevel_Level;
const ReadRequest = cloudApi.logging.log_reading_service.ReadRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.LogReadingServiceClient);

const result = await client.read(
ReadRequest.fromPartial({
// pageToken: "pageToken",
// criteria: {
// logGroupId: "logGroupId",
// resourceTypes: ["resourceTypes"],
// resourceIds: ["resourceIds"],
// since: {
// seconds: 0,
// nanos: 0
// },
// until: {
// seconds: 0,
// nanos: 0
// },
// levels: [LogLevel_Level.TRACE],
// filter: "filter",
// streamNames: ["streamNames"],
// pageSize: 0,
// maxResponseSize: 0
// }
})
);
console.log(result);
})();

ReadRequest​

One of selector​

Read selector.

See Criteria for details.

Criteria​

Read criteria. Should be used in initial ReadRequest.

logGroupId : string​

ID of the log group to return.

To get a log group ID make a LogGroupService.List request.

resourceTypes : string​

List of resource types to limit log entries to.

Empty list disables filter.

resourceIds : string​

List of resource IDs to limit log entries to.

Empty list disables filter.

since : google.protobuf.Timestamp​

Lower bound of log entries timestamps.

until : google.protobuf.Timestamp​

Upper bound of log entries timestamps.

levels : LogLevel.Level​

List of log levels to limit log entries to.

Empty list disables filter.

filter : string​

Filter expression. For details about filtering, see documentation.

streamNames : string​

List of stream names to limit log entries to.

Empty list disables filter.

pageSize : int64​

The maximum number of results per page to return.

maxResponseSize : int64​

Limits response to maximum size in bytes. Prevents gRPC resource exhaustion.

Default value for max response size is 3.5 MiB

ReadResponse​

logGroupId : string​

Log group ID the read was performed from.

entries : LogEntry​

List of matching log entries.

nextPageToken : string​

Token for getting the next page of the log entries.

After getting log entries initially with Criteria, you can use next_page_token as the value for the ReadRequest.page_token parameter in the next read request.

Each subsequent page will have its own next_page_token to continue paging through the results.

previousPageToken : string​

Token for getting the previous page of the log entries.

After getting log entries initially with Criteria, you can use previous_page_token as the value for the ReadRequest.page_token parameter in the next read request.

Each subsequent page will have its own next_page_token to continue paging through the results.

LogEntry​

uid : string​

Unique entry ID.

Useful for logs deduplication.

resource : LogEntryResource​

Entry resource specification.

May contain information about source service and resource ID. Also may be provided by the user.

timestamp : google.protobuf.Timestamp​

Timestamp of the entry.

ingestedAt : google.protobuf.Timestamp​

Entry ingestion time observed by LogIngestionService.

savedAt : google.protobuf.Timestamp​

Entry save time.

Entry is ready to be read since this moment.

level : LogLevel.Level​

Entry severity.

See LogLevel.Level for details.

message : string​

Entry text message.

jsonPayload : google.protobuf.Struct​

Entry annotation.

streamName : string​

Entry stream name.

LogEntryResource​

Log entry resource specification.

May be used either by services and by user.

type : string​

Resource type, i.e., serverless.function

id : string​

Resource ID, i.e., ID of the function producing logs.