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 bet 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// ChannelRef 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 int64 socket_id = 3; 181 // An optional name associated with the socket. 182 string name = 4; 183 // Intentionally don't use field numbers from other refs. 184 reserved 1, 2, 5, 6, 7, 8; 185} 186 187// ServerRef is a reference to a Server. 188message ServerRef { 189 // A globally unique identifier for this server. Must be a positive number. 190 int64 server_id = 5; 191 // An optional name associated with the server. 192 string name = 6; 193 // Intentionally don't use field numbers from other refs. 194 reserved 1, 2, 3, 4, 7, 8; 195} 196 197// Server represents a single server. There may be multiple servers in a single 198// program. 199message Server { 200 // The identifier for a Server. This should be set. 201 ServerRef ref = 1; 202 // The associated data of the Server. 203 ServerData data = 2; 204 205 // The sockets that the server is listening on. There are no ordering 206 // guarantees. This may be absent. 207 repeated SocketRef listen_socket = 3; 208} 209 210// ServerData is data for a specific Server. 211message ServerData { 212 // A trace of recent events on the server. May be absent. 213 ChannelTrace trace = 1; 214 215 // The number of incoming calls started on the server 216 int64 calls_started = 2; 217 // The number of incoming calls that have completed with an OK status 218 int64 calls_succeeded = 3; 219 // The number of incoming calls that have a completed with a non-OK status 220 int64 calls_failed = 4; 221 222 // The last time a call was started on the server. 223 google.protobuf.Timestamp last_call_started_timestamp = 5; 224} 225 226// Information about an actual connection. Pronounced "sock-ay". 227message Socket { 228 // The identifier for the Socket. 229 SocketRef ref = 1; 230 231 // Data specific to this Socket. 232 SocketData data = 2; 233 // The locally bound address. 234 Address local = 3; 235 // The remote bound address. May be absent. 236 Address remote = 4; 237 // Security details for this socket. May be absent if not available, or 238 // there is no security on the socket. 239 Security security = 5; 240 241 // Optional, represents the name of the remote endpoint, if different than 242 // the original target name. 243 string remote_name = 6; 244} 245 246// SocketData is data associated for a specific Socket. The fields present 247// are specific to the implementation, so there may be minor differences in 248// the semantics. (e.g. flow control windows) 249message SocketData { 250 // The number of streams that have been started. 251 int64 streams_started = 1; 252 // The number of streams that have ended successfully: 253 // On client side, received frame with eos bit set; 254 // On server side, sent frame with eos bit set. 255 int64 streams_succeeded = 2; 256 // The number of streams that have ended unsuccessfully: 257 // On client side, ended without receiving frame with eos bit set; 258 // On server side, ended without sending frame with eos bit set. 259 int64 streams_failed = 3; 260 // The number of grpc messages successfully sent on this socket. 261 int64 messages_sent = 4; 262 // The number of grpc messages received on this socket. 263 int64 messages_received = 5; 264 265 // The number of keep alives sent. This is typically implemented with HTTP/2 266 // ping messages. 267 int64 keep_alives_sent = 6; 268 269 // The last time a stream was created by this endpoint. Usually unset for 270 // servers. 271 google.protobuf.Timestamp last_local_stream_created_timestamp = 7; 272 // The last time a stream was created by the remote endpoint. Usually unset 273 // for clients. 274 google.protobuf.Timestamp last_remote_stream_created_timestamp = 8; 275 276 // The last time a message was sent by this endpoint. 277 google.protobuf.Timestamp last_message_sent_timestamp = 9; 278 // The last time a message was received by this endpoint. 279 google.protobuf.Timestamp last_message_received_timestamp = 10; 280 281 // The amount of window, granted to the local endpoint by the remote endpoint. 282 // This may be slightly out of date due to network latency. This does NOT 283 // include stream level or TCP level flow control info. 284 google.protobuf.Int64Value local_flow_control_window = 11; 285 286 // The amount of window, granted to the remote endpoint by the local endpoint. 287 // This may be slightly out of date due to network latency. This does NOT 288 // include stream level or TCP level flow control info. 289 google.protobuf.Int64Value remote_flow_control_window = 12; 290 291 // Socket options set on this socket. May be absent. 292 repeated SocketOption option = 13; 293} 294 295// Address represents the address used to create the socket. 296message Address { 297 message TcpIpAddress { 298 // Either the IPv4 or IPv6 address in bytes. Will be either 4 bytes or 16 299 // bytes in length. 300 bytes ip_address = 1; 301 // 0-64k, or -1 if not appropriate. 302 int32 port = 2; 303 } 304 // A Unix Domain Socket address. 305 message UdsAddress { 306 string filename = 1; 307 } 308 // An address type not included above. 309 message OtherAddress { 310 // The human readable version of the value. This value should be set. 311 string name = 1; 312 // The actual address message. 313 google.protobuf.Any value = 2; 314 } 315 316 oneof address { 317 TcpIpAddress tcpip_address = 1; 318 UdsAddress uds_address = 2; 319 OtherAddress other_address = 3; 320 } 321} 322 323// Security represents details about how secure the socket is. 324message Security { 325 message Tls { 326 oneof cipher_suite { 327 // The cipher suite name in the RFC 4346 format: 328 // https://tools.ietf.org/html/rfc4346#appendix-C 329 string standard_name = 1; 330 // Some other way to describe the cipher suite if 331 // the RFC 4346 name is not available. 332 string other_name = 2; 333 } 334 // the certificate used by this endpoint. 335 bytes local_certificate = 3; 336 // the certificate used by the remote endpoint. 337 bytes remote_certificate = 4; 338 } 339 message OtherSecurity { 340 // The human readable version of the value. 341 string name = 1; 342 // The actual security details message. 343 google.protobuf.Any value = 2; 344 } 345 oneof model { 346 Tls tls = 1; 347 OtherSecurity other = 2; 348 } 349} 350 351// SocketOption represents socket options for a socket. Specifically, these 352// are the options returned by getsockopt(). 353message SocketOption { 354 // The full name of the socket option. Typically this will be the upper case 355 // name, such as "SO_REUSEPORT". 356 string name = 1; 357 // The human readable value of this socket option. At least one of value or 358 // additional will be set. 359 string value = 2; 360 // Additional data associated with the socket option. At least one of value 361 // or additional will be set. 362 google.protobuf.Any additional = 3; 363} 364 365// For use with SocketOption's additional field. This is primarily used for 366// SO_RCVTIMEO and SO_SNDTIMEO 367message SocketOptionTimeout { 368 google.protobuf.Duration duration = 1; 369} 370 371// For use with SocketOption's additional field. This is primarily used for 372// SO_LINGER. 373message SocketOptionLinger { 374 // active maps to `struct linger.l_onoff` 375 bool active = 1; 376 // duration maps to `struct linger.l_linger` 377 google.protobuf.Duration duration = 2; 378} 379 380// For use with SocketOption's additional field. Tcp info for 381// SOL_TCP and TCP_INFO. 382message SocketOptionTcpInfo { 383 uint32 tcpi_state = 1; 384 385 uint32 tcpi_ca_state = 2; 386 uint32 tcpi_retransmits = 3; 387 uint32 tcpi_probes = 4; 388 uint32 tcpi_backoff = 5; 389 uint32 tcpi_options = 6; 390 uint32 tcpi_snd_wscale = 7; 391 uint32 tcpi_rcv_wscale = 8; 392 393 uint32 tcpi_rto = 9; 394 uint32 tcpi_ato = 10; 395 uint32 tcpi_snd_mss = 11; 396 uint32 tcpi_rcv_mss = 12; 397 398 uint32 tcpi_unacked = 13; 399 uint32 tcpi_sacked = 14; 400 uint32 tcpi_lost = 15; 401 uint32 tcpi_retrans = 16; 402 uint32 tcpi_fackets = 17; 403 404 uint32 tcpi_last_data_sent = 18; 405 uint32 tcpi_last_ack_sent = 19; 406 uint32 tcpi_last_data_recv = 20; 407 uint32 tcpi_last_ack_recv = 21; 408 409 uint32 tcpi_pmtu = 22; 410 uint32 tcpi_rcv_ssthresh = 23; 411 uint32 tcpi_rtt = 24; 412 uint32 tcpi_rttvar = 25; 413 uint32 tcpi_snd_ssthresh = 26; 414 uint32 tcpi_snd_cwnd = 27; 415 uint32 tcpi_advmss = 28; 416 uint32 tcpi_reordering = 29; 417} 418 419// Channelz is a service exposed by gRPC servers that provides detailed debug 420// information. 421service Channelz { 422 // Gets all root channels (i.e. channels the application has directly 423 // created). This does not include subchannels nor non-top level channels. 424 rpc GetTopChannels(GetTopChannelsRequest) returns (GetTopChannelsResponse); 425 // Gets all servers that exist in the process. 426 rpc GetServers(GetServersRequest) returns (GetServersResponse); 427 // Gets all server sockets that exist in the process. 428 rpc GetServerSockets(GetServerSocketsRequest) returns (GetServerSocketsResponse); 429 // Returns a single Channel, or else a NOT_FOUND code. 430 rpc GetChannel(GetChannelRequest) returns (GetChannelResponse); 431 // Returns a single Subchannel, or else a NOT_FOUND code. 432 rpc GetSubchannel(GetSubchannelRequest) returns (GetSubchannelResponse); 433 // Returns a single Socket or else a NOT_FOUND code. 434 rpc GetSocket(GetSocketRequest) returns (GetSocketResponse); 435} 436 437message GetTopChannelsRequest { 438 // start_channel_id indicates that only channels at or above this id should be 439 // included in the results. 440 int64 start_channel_id = 1; 441} 442 443message GetTopChannelsResponse { 444 // list of channels that the connection detail service knows about. Sorted in 445 // ascending channel_id order. 446 repeated Channel channel = 1; 447 // If set, indicates that the list of channels is the final list. Requesting 448 // more channels can only return more if they are created after this RPC 449 // completes. 450 bool end = 2; 451} 452 453message GetServersRequest { 454 // start_server_id indicates that only servers at or above this id should be 455 // included in the results. 456 int64 start_server_id = 1; 457} 458 459message GetServersResponse { 460 // list of servers that the connection detail service knows about. Sorted in 461 // ascending server_id order. 462 repeated Server server = 1; 463 // If set, indicates that the list of servers is the final list. Requesting 464 // more servers will only return more if they are created after this RPC 465 // completes. 466 bool end = 2; 467} 468 469message GetServerSocketsRequest { 470 int64 server_id = 1; 471 // start_socket_id indicates that only sockets at or above this id should be 472 // included in the results. 473 int64 start_socket_id = 2; 474} 475 476message GetServerSocketsResponse { 477 // list of socket refs that the connection detail service knows about. Sorted in 478 // ascending socket_id order. 479 repeated SocketRef socket_ref = 1; 480 // If set, indicates that the list of sockets is the final list. Requesting 481 // more sockets will only return more if they are created after this RPC 482 // completes. 483 bool end = 2; 484} 485 486message GetChannelRequest { 487 // channel_id is the the identifier of the specific channel to get. 488 int64 channel_id = 1; 489} 490 491message GetChannelResponse { 492 // The Channel that corresponds to the requested channel_id. This field 493 // should be set. 494 Channel channel = 1; 495} 496 497message GetSubchannelRequest { 498 // subchannel_id is the the identifier of the specific subchannel to get. 499 int64 subchannel_id = 1; 500} 501 502message GetSubchannelResponse { 503 // The Subchannel that corresponds to the requested subchannel_id. This 504 // field should be set. 505 Subchannel subchannel = 1; 506} 507 508message GetSocketRequest { 509 // socket_id is the the identifier of the specific socket to get. 510 int64 socket_id = 1; 511} 512 513message GetSocketResponse { 514 // The Socket that corresponds to the requested socket_id. This field 515 // should be set. 516 Socket socket = 1; 517} 518