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
ServiceType
SERVICE_TYPE_UNSPECIFIED
REDIS
Logs of Redis activity.
clusterId
: string
Required. ID of the Redis 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:
- The field name. Currently filtering can be applied to the LogRecord.logs.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]
. Examples of a filtermessage.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.