StreamLogs
Same as ListLogs but using server-side streaming. Also allows for tail -f
semantics.
- TypeScript
- Python
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);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.dataproc.v1.cluster_service_pb2_grpc import ClusterServiceStub
from yandex.cloud.mdb.clickhouse.v1.cluster_service_pb2 import StreamClusterLogsRequest
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(ClusterServiceStub)
response = service.streamLogs()
print(response)
StreamClusterLogsRequest
clusterId
: string
ID of the Apache Kafka® cluster.
To get the Apache Kafka® cluster ID, make a ClusterService.List request.
columnFilter
: string
Columns from logs table to get in the response.
If no columns are specified, full log records are returned.
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 StreamLogRecord.next_record_token returned by a previous ClusterService.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:
- The field name to filter by. Currently filtering can be applied to the
hostname
field. - An
=
operator. - The value in double quotes (
"
). Must be 3-63 characters long and match the regular expression[a-z][-a-z0-9]{1,61}[a-z0-9]
.
Example of a filter: 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 StreamClusterLogsRequest.record_token parameter in the next StreamLogs request.
This value is interchangeable with ListClusterLogsResponse.next_page_token from ListLogs method.
LogRecord
A single log record.
timestamp
: google.protobuf.Timestamp
Log record timestamp.
message
: string
Contents of the log record.