3 package docker.swarmkit.v1;
5 import "gogoproto/gogo.proto";
6 import "google/protobuf/timestamp.proto";
7 import "plugin/plugin.proto";
9 // LogStream defines the stream from which the log message came.
11 option (gogoproto.goproto_enum_prefix) = false;
12 option (gogoproto.enum_customname) = "LogStream";
14 LOG_STREAM_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "LogStreamUnknown"];
15 LOG_STREAM_STDOUT = 1 [(gogoproto.enumvalue_customname) = "LogStreamStdout"];
16 LOG_STREAM_STDERR = 2 [(gogoproto.enumvalue_customname) = "LogStreamStderr"];
19 message LogSubscriptionOptions {
20 // Streams defines which log streams should be sent from the task source.
21 // Empty means send all the messages.
22 repeated LogStream streams = 1 [packed=false];
24 // Follow instructs the publisher to continue sending log messages as they
25 // are produced, after satisfying the initial query.
28 // Tail defines how many messages relative to the log stream to send when
29 // starting the stream.
31 // Positive values will skip that number of messages from the start of the
32 // stream before publishing.
34 // Negative values will specify messages relative to the end of the stream,
35 // offset by one. We can say that the last (-n-1) lines are returned when n
36 // < 0. As reference, -1 would mean send no log lines (typically used with
37 // follow), -2 would return the last log line, -11 would return the last 10
40 // The default value of zero will return all logs.
42 // Note that this is very different from the Docker API.
45 // Since indicates that only log messages produced after this timestamp
47 // Note: can't use stdtime because this field is nullable.
48 google.protobuf.Timestamp since = 4;
51 // LogSelector will match logs from ANY of the defined parameters.
53 // For the best effect, the client should use the least specific parameter
54 // possible. For example, if they want to listen to all the tasks of a service,
55 // they should use the service id, rather than specifying the individual tasks.
57 repeated string service_ids = 1;
58 repeated string node_ids = 2;
59 repeated string task_ids = 3;
62 // LogContext marks the context from which a log message was generated.
64 string service_id = 1;
69 // LogAttr is an extra key/value pair that may be have been set by users
77 // Context identifies the source of the log message.
78 LogContext context = 1 [(gogoproto.nullable) = false];
80 // Timestamp is the time at which the message was generated.
81 // Note: can't use stdtime because this field is nullable.
82 google.protobuf.Timestamp timestamp = 2;
84 // Stream identifies the stream of the log message, stdout or stderr.
87 // Data is the raw log message, as generated by the application.
90 // Attrs is a list of key value pairs representing additional log details
91 // that may have been returned from the logger
92 repeated LogAttr attrs = 5 [(gogoproto.nullable) = false];
95 // Logs defines the methods for retrieving task logs messages from a cluster.
97 // SubscribeLogs starts a subscription with the specified selector and options.
99 // The subscription will be distributed to relevant nodes and messages will
100 // be collected and sent via the returned stream.
102 // The subscription will end with an EOF.
103 rpc SubscribeLogs(SubscribeLogsRequest) returns (stream SubscribeLogsMessage) {
104 option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" };
108 message SubscribeLogsRequest {
109 // LogSelector describes the logs to which the subscriber is
110 LogSelector selector = 1;
112 LogSubscriptionOptions options = 2;
115 message SubscribeLogsMessage {
116 repeated LogMessage messages = 1 [(gogoproto.nullable) = false];
119 // LogBroker defines the API used by the worker to send task logs back to a
120 // manager. A client listens for subscriptions then optimistically retrieves
121 // logs satisfying said subscriptions, calling PublishLogs for results that are
124 // The structure of ListenSubscriptions is similar to the Dispatcher API but
125 // decoupled to allow log distribution to work outside of the regular task
128 // ListenSubscriptions starts a subscription stream for the node. For each
129 // message received, the node should attempt to satisfy the subscription.
131 // Log messages that match the provided subscription should be sent via
133 rpc ListenSubscriptions(ListenSubscriptionsRequest) returns (stream SubscriptionMessage) {
134 option (docker.protobuf.plugin.tls_authorization) = {
135 roles: "swarm-worker"
136 roles: "swarm-manager"
140 // PublishLogs receives sets of log messages destined for a single
141 // subscription identifier.
142 rpc PublishLogs(stream PublishLogsMessage) returns (PublishLogsResponse) {
143 option (docker.protobuf.plugin.tls_authorization) = {
144 roles: "swarm-worker"
145 roles: "swarm-manager"
150 // ListenSubscriptionsRequest is a placeholder to begin listening for
152 message ListenSubscriptionsRequest { }
154 // SubscriptionMessage instructs the listener to start publishing messages for
155 // the stream or end a subscription.
157 // If Options.Follow == false, the worker should end the subscription on its own.
158 message SubscriptionMessage {
159 // ID identifies the subscription.
162 // Selector defines which sources should be sent for the subscription.
163 LogSelector selector = 2;
165 // Options specify how the subscription should be satisfied.
166 LogSubscriptionOptions options = 3;
168 // Close will be true if the node should shutdown the subscription with the
169 // provided identifier.
173 message PublishLogsMessage {
174 // SubscriptionID identifies which subscription the set of messages should
175 // be sent to. We can think of this as a "mail box" for the subscription.
176 string subscription_id = 1;
178 // Messages is the log message for publishing.
179 repeated LogMessage messages = 2 [(gogoproto.nullable) = false];
181 // Close is a boolean for whether or not the client has completed its log
182 // stream. When close is called, the manager can hang up the subscription.
183 // Any further logs from this subscription are an error condition. Any
184 // messages included when close is set can be discarded
188 message PublishLogsResponse { }