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

    Type is not specified.

  • GREENPLUM

    Greenplum® activity logs.

  • GREENPLUM_POOLER

    Greenplum® pooler logs.

  • GREENPLUM_PXF

    Greenplum® PXF service logs.

clusterId : string

ID of the Greenplum® cluster.

columnFilter : string

Columns from log table to get in the response. If no columns are specified, entire log records are returned.

serviceType : ServiceType

Type of the service to request logs about.

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 are sent as well as the new ones as they appear.

In essence it has tail -f semantics.

recordToken : string

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

filter : string

A filter expression that filters resources listed in the response.

The expression must specify:

  1. A field name. Currently filtering can be applied to the LogRecord.logs.message.hostname, LogRecord.logs.message.error_severity (for GREENPLUM service), LogRecord.logs.message.level (for POOLER service) fields.

  2. An = operator.

  3. A 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 do that, specify value of next_record_token as the value for StreamLogs.record_token parameter in the next StreamLogs request.

This value is interchangeable with ListLogs.next_page_token from ListLogs method.

LogRecord

timestamp : google.protobuf.Timestamp

Time when the log was recorded.

message : string

Contents of the log record.