1// Copyright 2018 The gRPC Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// This file defines an interface for exporting monitoring information
16// out of gRPC servers.  See the full design at
17// https://github.com/grpc/proposal/blob/master/A14-channelz.md
18//
19// The canonical version of this proto can be found at
20// https://github.com/grpc/grpc-proto/blob/master/grpc/channelz/v1/channelz.proto
21
22syntax = "proto3";
23
24package grpc.channelz.v1;
25
26import "google/protobuf/any.proto";
27import "google/protobuf/duration.proto";
28import "google/protobuf/timestamp.proto";
29import "google/protobuf/wrappers.proto";
30
31option go_package = "google.golang.org/grpc/channelz/grpc_channelz_v1";
32option java_multiple_files = true;
33option java_package = "io.grpc.channelz.v1";
34option java_outer_classname = "ChannelzProto";
35
36// Channel is a logical grouping of channels, subchannels, and sockets.
37message Channel {
38  // The identifier for this channel. This should be set.
39  ChannelRef ref = 1;
40  // Data specific to this channel.
41  ChannelData data = 2;
42  // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
43
44  // There are no ordering guarantees on the order of channel refs.
45  // There may not be cycles in the ref graph.
46  // A channel ref may be present in more than one channel or subchannel.
47  repeated ChannelRef channel_ref = 3;
48
49  // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
50  // There are no ordering guarantees on the order of subchannel refs.
51  // There may not be cycles in the ref graph.
52  // A sub channel ref may be present in more than one channel or subchannel.
53  repeated SubchannelRef subchannel_ref = 4;
54
55  // There are no ordering guarantees on the order of sockets.
56  repeated SocketRef socket_ref = 5;
57}
58
59// Subchannel is a logical grouping of channels, subchannels, and sockets.
60// A subchannel is load balanced over by it's ancestor
61message Subchannel {
62  // The identifier for this channel.
63  SubchannelRef ref = 1;
64  // Data specific to this channel.
65  ChannelData data = 2;
66  // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
67
68  // There are no ordering guarantees on the order of channel refs.
69  // There may not be cycles in the ref graph.
70  // A channel ref may be present in more than one channel or subchannel.
71  repeated ChannelRef channel_ref = 3;
72
73  // At most one of 'channel_ref+subchannel_ref' and 'socket' is set.
74  // There are no ordering guarantees on the order of subchannel refs.
75  // There may not be cycles in the ref graph.
76  // A sub channel ref may be present in more than one channel or subchannel.
77  repeated SubchannelRef subchannel_ref = 4;
78
79  // There are no ordering guarantees on the order of sockets.
80  repeated SocketRef socket_ref = 5;
81}
82
83// These come from the specified states in this document:
84// https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
85message ChannelConnectivityState {
86  enum State {
87    UNKNOWN = 0;
88    IDLE = 1;
89    CONNECTING = 2;
90    READY = 3;
91    TRANSIENT_FAILURE = 4;
92    SHUTDOWN = 5;
93  }
94  State state = 1;
95}
96
97// Channel data is data related to a specific Channel or Subchannel.
98message ChannelData {
99  // The connectivity state of the channel or subchannel.  Implementations
100  // should always set this.
101  ChannelConnectivityState state = 1;
102
103  // The target this channel originally tried to connect to.  May be absent
104  string target = 2;
105
106  // A trace of recent events on the channel.  May be absent.
107  ChannelTrace trace = 3;
108
109  // The number of calls started on the channel
110  int64 calls_started = 4;
111  // The number of calls that have completed with an OK status
112  int64 calls_succeeded = 5;
113  // The number of calls that have completed with a non-OK status
114  int64 calls_failed = 6;
115
116  // The last time a call was started on the channel.
117  google.protobuf.Timestamp last_call_started_timestamp = 7;
118}
119
120// A trace event is an interesting thing that happened to a channel or
121// subchannel, such as creation, address resolution, subchannel creation, etc.
122message ChannelTraceEvent {
123  // High level description of the event.
124  string description = 1;
125  // The supported severity levels of trace events.
126  enum Severity {
127    CT_UNKNOWN = 0;
128    CT_INFO = 1;
129    CT_WARNING = 2;
130    CT_ERROR = 3;
131  }
132  // the severity of the trace event
133  Severity severity = 2;
134  // When this event occurred.
135  google.protobuf.Timestamp timestamp = 3;
136  // ref of referenced channel or subchannel.
137  // Optional, only present if this event refers to a child object. For example,
138  // this field would be filled if this trace event was for a subchannel being
139  // created.
140  oneof child_ref {
141    ChannelRef channel_ref = 4;
142    SubchannelRef subchannel_ref = 5;
143  }
144}
145
146// ChannelTrace represents the recent events that have occurred on the channel.
147message ChannelTrace {
148  // Number of events ever logged in this tracing object. This can differ from
149  // events.size() because events can be overwritten or garbage collected by
150  // implementations.
151  int64 num_events_logged = 1;
152  // Time that this channel was created.
153  google.protobuf.Timestamp creation_timestamp = 2;
154  // List of events that have occurred on this channel.
155  repeated ChannelTraceEvent events = 3;
156}
157
158// ChannelRef is a reference to a Channel.
159message ChannelRef {
160  // The globally unique id for this channel.  Must be a positive number.
161  int64 channel_id = 1;
162  // An optional name associated with the channel.
163  string name = 2;
164  // Intentionally don't use field numbers from other refs.
165  reserved 3, 4, 5, 6, 7, 8;
166}
167
168// SubchannelRef is a reference to a Subchannel.
169message SubchannelRef {
170  // The globally unique id for this subchannel.  Must be a positive number.
171  int64 subchannel_id = 7;
172  // An optional name associated with the subchannel.
173  string name = 8;
174  // Intentionally don't use field numbers from other refs.
175  reserved 1, 2, 3, 4, 5, 6;
176}
177
178// SocketRef is a reference to a Socket.
179message SocketRef {
180  // The globally unique id for this socket.  Must be a positive number.
181  int64 socket_id = 3;
182  // An optional name associated with the socket.
183  string name = 4;
184  // Intentionally don't use field numbers from other refs.
185  reserved 1, 2, 5, 6, 7, 8;
186}
187
188// ServerRef is a reference to a Server.
189message ServerRef {
190  // A globally unique identifier for this server.  Must be a positive number.
191  int64 server_id = 5;
192  // An optional name associated with the server.
193  string name = 6;
194  // Intentionally don't use field numbers from other refs.
195  reserved 1, 2, 3, 4, 7, 8;
196}
197
198// Server represents a single server.  There may be multiple servers in a single
199// program.
200message Server {
201  // The identifier for a Server.  This should be set.
202  ServerRef ref = 1;
203  // The associated data of the Server.
204  ServerData data = 2;
205
206  // The sockets that the server is listening on.  There are no ordering
207  // guarantees.  This may be absent.
208  repeated SocketRef listen_socket = 3;
209}
210
211// ServerData is data for a specific Server.
212message ServerData {
213  // A trace of recent events on the server.  May be absent.
214  ChannelTrace trace = 1;
215
216  // The number of incoming calls started on the server
217  int64 calls_started = 2;
218  // The number of incoming calls that have completed with an OK status
219  int64 calls_succeeded = 3;
220  // The number of incoming calls that have a completed with a non-OK status
221  int64 calls_failed = 4;
222
223  // The last time a call was started on the server.
224  google.protobuf.Timestamp last_call_started_timestamp = 5;
225}
226
227// Information about an actual connection.  Pronounced "sock-ay".
228message Socket {
229  // The identifier for the Socket.
230  SocketRef ref = 1;
231
232  // Data specific to this Socket.
233  SocketData data = 2;
234  // The locally bound address.
235  Address local = 3;
236  // The remote bound address.  May be absent.
237  Address remote = 4;
238  // Security details for this socket.  May be absent if not available, or
239  // there is no security on the socket.
240  Security security = 5;
241
242  // Optional, represents the name of the remote endpoint, if different than
243  // the original target name.
244  string remote_name = 6;
245}
246
247// SocketData is data associated for a specific Socket.  The fields present
248// are specific to the implementation, so there may be minor differences in
249// the semantics.  (e.g. flow control windows)
250message SocketData {
251  // The number of streams that have been started.
252  int64 streams_started = 1;
253  // The number of streams that have ended successfully:
254  // On client side, received frame with eos bit set;
255  // On server side, sent frame with eos bit set.
256  int64 streams_succeeded = 2;
257  // The number of streams that have ended unsuccessfully:
258  // On client side, ended without receiving frame with eos bit set;
259  // On server side, ended without sending frame with eos bit set.
260  int64 streams_failed = 3;
261  // The number of grpc messages successfully sent on this socket.
262  int64 messages_sent = 4;
263  // The number of grpc messages received on this socket.
264  int64 messages_received = 5;
265
266  // The number of keep alives sent.  This is typically implemented with HTTP/2
267  // ping messages.
268  int64 keep_alives_sent = 6;
269
270  // The last time a stream was created by this endpoint.  Usually unset for
271  // servers.
272  google.protobuf.Timestamp last_local_stream_created_timestamp = 7;
273  // The last time a stream was created by the remote endpoint.  Usually unset
274  // for clients.
275  google.protobuf.Timestamp last_remote_stream_created_timestamp = 8;
276
277  // The last time a message was sent by this endpoint.
278  google.protobuf.Timestamp last_message_sent_timestamp = 9;
279  // The last time a message was received by this endpoint.
280  google.protobuf.Timestamp last_message_received_timestamp = 10;
281
282  // The amount of window, granted to the local endpoint by the remote endpoint.
283  // This may be slightly out of date due to network latency.  This does NOT
284  // include stream level or TCP level flow control info.
285  google.protobuf.Int64Value local_flow_control_window = 11;
286
287  // The amount of window, granted to the remote endpoint by the local endpoint.
288  // This may be slightly out of date due to network latency.  This does NOT
289  // include stream level or TCP level flow control info.
290  google.protobuf.Int64Value  remote_flow_control_window = 12;
291
292  // Socket options set on this socket.  May be absent if 'summary' is set
293  // on GetSocketRequest.
294  repeated SocketOption option = 13;
295}
296
297// Address represents the address used to create the socket.
298message Address {
299  message TcpIpAddress {
300    // Either the IPv4 or IPv6 address in bytes.  Will be either 4 bytes or 16
301    // bytes in length.
302    bytes ip_address = 1;
303    // 0-64k, or -1 if not appropriate.
304    int32 port = 2;
305  }
306  // A Unix Domain Socket address.
307  message UdsAddress {
308    string filename = 1;
309  }
310  // An address type not included above.
311  message OtherAddress {
312    // The human readable version of the value.  This value should be set.
313    string name = 1;
314    // The actual address message.
315    google.protobuf.Any value = 2;
316  }
317
318  oneof address {
319    TcpIpAddress tcpip_address = 1;
320    UdsAddress uds_address = 2;
321    OtherAddress other_address = 3;
322  }
323}
324
325// Security represents details about how secure the socket is.
326message Security {
327  message Tls {
328    oneof cipher_suite {
329      // The cipher suite name in the RFC 4346 format:
330      // https://tools.ietf.org/html/rfc4346#appendix-C
331      string standard_name = 1;
332      // Some other way to describe the cipher suite if
333      // the RFC 4346 name is not available.
334      string other_name = 2;
335    }
336    // the certificate used by this endpoint.
337    bytes local_certificate = 3;
338    // the certificate used by the remote endpoint.
339    bytes remote_certificate = 4;
340  }
341  message OtherSecurity {
342    // The human readable version of the value.
343    string name = 1;
344    // The actual security details message.
345    google.protobuf.Any value = 2;
346  }
347  oneof model {
348    Tls tls = 1;
349    OtherSecurity other = 2;
350  }
351}
352
353// SocketOption represents socket options for a socket.  Specifically, these
354// are the options returned by getsockopt().
355message SocketOption {
356  // The full name of the socket option.  Typically this will be the upper case
357  // name, such as "SO_REUSEPORT".
358  string name = 1;
359  // The human readable value of this socket option.  At least one of value or
360  // additional will be set.
361  string value = 2;
362  // Additional data associated with the socket option.  At least one of value
363  // or additional will be set.
364  google.protobuf.Any additional = 3;
365}
366
367// For use with SocketOption's additional field.  This is primarily used for
368// SO_RCVTIMEO and SO_SNDTIMEO
369message SocketOptionTimeout {
370  google.protobuf.Duration duration = 1;
371}
372
373// For use with SocketOption's additional field.  This is primarily used for
374// SO_LINGER.
375message SocketOptionLinger {
376  // active maps to `struct linger.l_onoff`
377  bool active = 1;
378  // duration maps to `struct linger.l_linger`
379  google.protobuf.Duration duration = 2;
380}
381
382// For use with SocketOption's additional field.  Tcp info for
383// SOL_TCP and TCP_INFO.
384message SocketOptionTcpInfo {
385  uint32 tcpi_state = 1;
386
387  uint32 tcpi_ca_state = 2;
388  uint32 tcpi_retransmits = 3;
389  uint32 tcpi_probes = 4;
390  uint32 tcpi_backoff = 5;
391  uint32 tcpi_options = 6;
392  uint32 tcpi_snd_wscale = 7;
393  uint32 tcpi_rcv_wscale = 8;
394
395  uint32 tcpi_rto = 9;
396  uint32 tcpi_ato = 10;
397  uint32 tcpi_snd_mss = 11;
398  uint32 tcpi_rcv_mss = 12;
399
400  uint32 tcpi_unacked = 13;
401  uint32 tcpi_sacked = 14;
402  uint32 tcpi_lost = 15;
403  uint32 tcpi_retrans = 16;
404  uint32 tcpi_fackets = 17;
405
406  uint32 tcpi_last_data_sent = 18;
407  uint32 tcpi_last_ack_sent = 19;
408  uint32 tcpi_last_data_recv = 20;
409  uint32 tcpi_last_ack_recv = 21;
410
411  uint32 tcpi_pmtu = 22;
412  uint32 tcpi_rcv_ssthresh = 23;
413  uint32 tcpi_rtt = 24;
414  uint32 tcpi_rttvar = 25;
415  uint32 tcpi_snd_ssthresh = 26;
416  uint32 tcpi_snd_cwnd = 27;
417  uint32 tcpi_advmss = 28;
418  uint32 tcpi_reordering = 29;
419}
420
421// Channelz is a service exposed by gRPC servers that provides detailed debug
422// information.
423service Channelz {
424  // Gets all root channels (i.e. channels the application has directly
425  // created). This does not include subchannels nor non-top level channels.
426  rpc GetTopChannels(GetTopChannelsRequest) returns (GetTopChannelsResponse);
427  // Gets all servers that exist in the process.
428  rpc GetServers(GetServersRequest) returns (GetServersResponse);
429  // Returns a single Server, or else a NOT_FOUND code.
430  rpc GetServer(GetServerRequest) returns (GetServerResponse);
431  // Gets all server sockets that exist in the process.
432  rpc GetServerSockets(GetServerSocketsRequest) returns (GetServerSocketsResponse);
433  // Returns a single Channel, or else a NOT_FOUND code.
434  rpc GetChannel(GetChannelRequest) returns (GetChannelResponse);
435  // Returns a single Subchannel, or else a NOT_FOUND code.
436  rpc GetSubchannel(GetSubchannelRequest) returns (GetSubchannelResponse);
437  // Returns a single Socket or else a NOT_FOUND code.
438  rpc GetSocket(GetSocketRequest) returns (GetSocketResponse);
439}
440
441message GetTopChannelsRequest {
442  // start_channel_id indicates that only channels at or above this id should be
443  // included in the results.
444  // To request the first page, this should be set to 0. To request
445  // subsequent pages, the client generates this value by adding 1 to
446  // the highest seen result ID.
447  int64 start_channel_id = 1;
448
449  // If non-zero, the server will return a page of results containing
450  // at most this many items. If zero, the server will choose a
451  // reasonable page size.  Must never be negative.
452  int64 max_results = 2;
453}
454
455message GetTopChannelsResponse {
456  // list of channels that the connection detail service knows about.  Sorted in
457  // ascending channel_id order.
458  // Must contain at least 1 result, otherwise 'end' must be true.
459  repeated Channel channel = 1;
460  // If set, indicates that the list of channels is the final list.  Requesting
461  // more channels can only return more if they are created after this RPC
462  // completes.
463  bool end = 2;
464}
465
466message GetServersRequest {
467  // start_server_id indicates that only servers at or above this id should be
468  // included in the results.
469  // To request the first page, this must be set to 0. To request
470  // subsequent pages, the client generates this value by adding 1 to
471  // the highest seen result ID.
472  int64 start_server_id = 1;
473
474  // If non-zero, the server will return a page of results containing
475  // at most this many items. If zero, the server will choose a
476  // reasonable page size.  Must never be negative.
477  int64 max_results = 2;
478}
479
480message GetServersResponse {
481  // list of servers that the connection detail service knows about.  Sorted in
482  // ascending server_id order.
483  // Must contain at least 1 result, otherwise 'end' must be true.
484  repeated Server server = 1;
485  // If set, indicates that the list of servers is the final list.  Requesting
486  // more servers will only return more if they are created after this RPC
487  // completes.
488  bool end = 2;
489}
490
491message GetServerRequest {
492  // server_id is the identifier of the specific server to get.
493  int64 server_id = 1;
494}
495
496message GetServerResponse {
497  // The Server that corresponds to the requested server_id.  This field
498  // should be set.
499  Server server = 1;
500}
501
502message GetServerSocketsRequest {
503  int64 server_id = 1;
504  // start_socket_id indicates that only sockets at or above this id should be
505  // included in the results.
506  // To request the first page, this must be set to 0. To request
507  // subsequent pages, the client generates this value by adding 1 to
508  // the highest seen result ID.
509  int64 start_socket_id = 2;
510
511  // If non-zero, the server will return a page of results containing
512  // at most this many items. If zero, the server will choose a
513  // reasonable page size.  Must never be negative.
514  int64 max_results = 3;
515}
516
517message GetServerSocketsResponse {
518  // list of socket refs that the connection detail service knows about.  Sorted in
519  // ascending socket_id order.
520  // Must contain at least 1 result, otherwise 'end' must be true.
521  repeated SocketRef socket_ref = 1;
522  // If set, indicates that the list of sockets is the final list.  Requesting
523  // more sockets will only return more if they are created after this RPC
524  // completes.
525  bool end = 2;
526}
527
528message GetChannelRequest {
529  // channel_id is the identifier of the specific channel to get.
530  int64 channel_id = 1;
531}
532
533message GetChannelResponse {
534  // The Channel that corresponds to the requested channel_id.  This field
535  // should be set.
536  Channel channel = 1;
537}
538
539message GetSubchannelRequest {
540  // subchannel_id is the identifier of the specific subchannel to get.
541  int64 subchannel_id = 1;
542}
543
544message GetSubchannelResponse {
545  // The Subchannel that corresponds to the requested subchannel_id.  This
546  // field should be set.
547  Subchannel subchannel = 1;
548}
549
550message GetSocketRequest {
551  // socket_id is the identifier of the specific socket to get.
552  int64 socket_id = 1;
553
554  // If true, the response will contain only high level information
555  // that is inexpensive to obtain. Fields thay may be omitted are
556  // documented.
557  bool summary = 2;
558}
559
560message GetSocketResponse {
561  // The Socket that corresponds to the requested socket_id.  This field
562  // should be set.
563  Socket socket = 1;
564}
565