Skip to main content

StreamLogs

Same as ListLogs but using server-side streaming. Also allows for 'tail -f' semantics.

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

const StreamClusterLogsRequest =
cloudApi.mdb.clickhouse_cluster_service.StreamClusterLogsRequest;
const StreamClusterLogsRequest_ServiceType =
cloudApi.mdb.clickhouse_cluster_service.StreamClusterLogsRequest_ServiceType;

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

const result = await client.streamLogs(
StreamClusterLogsRequest.fromPartial({
clusterId: "clusterId",
// columnFilter: ["columnFilter"],
serviceType: StreamClusterLogsRequest_ServiceType.CLICKHOUSE,
// fromTime: {
// seconds: 0,
// nanos: 0
// },
// toTime: {
// seconds: 0,
// nanos: 0
// },
// recordToken: "recordToken",
// filter: "filter"
})
);
console.log(result);
})();

StreamClusterLogsRequest​

ServiceType​

  • SERVICE_TYPE_UNSPECIFIED

  • POSTGRESQL

    Logs of PostgreSQL activity.

  • POOLER

    Logs of connection pooler activity.

clusterId : string​

Required. ID of the PostgreSQL cluster.

columnFilter : string​

Columns from logs table to get in the response.

serviceType : ServiceType​
fromTime : google.protobuf.Timestamp​

Start timestamp for the logs request.

toTime : google.protobuf.Timestamp​

End timestamp for the logs request. If this field is not set, all existing logs will be sent and then the new ones as they appear. In essence it has 'tail -f' semantics.

recordToken : string​

Record token. Set record_token to the next_record_token returned by a previous StreamLogs request to start streaming from next log record.

filter : string​

A filter expression that filters resources listed in the response. The expression must specify:

  1. The field name. Currently filtering can be applied to the LogRecord.logs.message.hostname, LogRecord.logs.message.error_severity (for POSTGRESQL service), LogRecord.logs.message.level (for POOLER service) fields.
  2. An = operator.
  3. The value in double quotes ("). Must be 1-63 characters long and match the regular expression [a-z0-9.-]{1,61}. Examples of a filter: message.hostname='node1.db.cloud.yandex.net'message.error_severity IN ("ERROR", "FATAL", "PANIC") AND message.hostname = "node1.db.cloud.yandex.net"

StreamLogRecord​

record : LogRecord​

One of the requested log records.

nextRecordToken : string​

This token allows you to continue streaming logs starting from the exact same record. To continue streaming, specify value of next_record_token as value for record_token parameter in the next StreamLogs request. This value is interchangeable with next_page_token from ListLogs method.

LogRecord​

timestamp : google.protobuf.Timestamp​

Log record timestamp in RFC3339 text format.

message : string​

Contents of the log record.