百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

grpcdebug

> 开发工具
开源

grpcdebug 是一个命令行接口,专注于简化 gRPC 应用程序的调试过程。

194 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

grpcdebug 是一个命令行接口,专注于简化 gRPC 应用程序的调试过程。

grpcdebug

grpcdebug is a command line interface focusing on simplifying the debugging process of gRPC applications. grpcdebug fetches the internal states of the gRPC library from the application via gRPC protocol and provide a human-friendly UX to browse them. Currently, it supports Channelz/Health Checking/CSDS (aka. admin services). In other words, it can fetch statistics about how many RPCs has being sent or failed on a given gRPC channel, it can inspect address resolution results, it can dump the in-effective xDS configuration that directs the routing of RPCs.

If you are looking for a tool to send gRPC requests and interact with a gRPC server, please checkout https://github.com/fullstorydev/grpcurl.

…

Table of Contents

  • grpcdebug
    • Table of Contents
    • Installation
      • Use Compiled Binaries
      • Compile From Source
    • Quick Start
      • Connect & Security
        • Insecure Connection
        • TLS Connection - Flags
        • Server Connection Config
      • Health
      • Channelz
        • Usage 1: Raw Channelz Output
        • Usage 2: List Client Channels
        • Usage 3: List Servers
        • Usage 4: Inspect a Channel
        • Usage 5: Inspect a Subchannel
        • Usage 6: Inspect a Socket
        • Usage 7: Inspect a Server
        • Usage 8: Pagination
      • Debug xDS
        • Usage 1: xDS Resources Overview
        • Usage 2: Dump xDS Configs
        • Usage 3: Filter xDS Configs
    • Admin Services
      • gRPC Java:
      • gRPC Go:
      • gRPC C++:

Installation

Use Compiled Binaries

The download links of the binaries can be found at https://github.com/grpc-ecosystem/grpcdebug/releases. You can find the precompiled artifacts for macOS/Linux/Windows.

Compile From Source

Minimum Golang Version 1.22. Official Golang install guide: https://golang.org/doc/install.

You can install the grpcdebug tool using command:

bash
go install -v github.com/grpc-ecosystem/grpcdebug@latest

You can check your Golang version with:

bash
go version

Don't forget to add Golang binaries to your PATH:

bash
export PATH=$PATH:$(go env GOPATH)/bin

Quick Start

If certain commands are confusing, please try to use -h to get more context. Suggestions and ideas are welcome, please post them to https://github.com/grpc-ecosystem/grpcdebug/issues!

If you haven't got your gRPC application instrumented, feel free to try out the mocking testserver which implemented admin services.

bash
cd internal/testing/testserver
go run main.go
# Serving Business Logic on :10001
# Serving Insecure Admin Services on :50051
# Serving Secure Admin Services on :50052
# ...

Connect & Security

Insecure Connection

To connect to a gRPC endpoint without any credentials, we don't use any special flags. If the local network can connect to the given gRPC endpoint, it should just work. For example, if I have a gRPC application exposing admin services at localhost:50051:

bash
grpcdebug localhost:50051 channelz channels

TLS Connection - Flags

One way to establish a TLS connection with grpcdebug is by specifying the credentials via command line flags. For example:

bash
grpcdebug localhost:50052 --security=tls --credential_file=./internal/testing/ca.pem --server_name_override="*.test.youtube.com" channelz channels

Server Connection Config

Alternatively, like OpenSSH clients, you can specify the security settings in a grpcdebug_config.yaml file. grpcdebug CLI will find matching connection config and then use it to connect.

yaml
servers:
  "pattern string":
    real_address: string
    security: insecure/tls
    credential_file: string
    server_name_override: string

Here is an example config file grpcdebug_config.yaml.

Each server config can have the following settings:

  • Pattern: the string right after Server which dictates if this rule should apply;
  • RealAddress: if present, override the given target address, which allows giving nicknames/aliases to frequently used addresses;
  • Security: allows insecure or tls, expecting more in the future;
  • CredentialFile: path to the credential file;
  • ServerNameOverride: override the hostname, which is useful for local reproductions to comply with the certificates' common name requirement.

grpcdebug searches the config file in the following order:

  1. Check if the environment variable GRPCDEBUG_CONFIG is set, if so, load from the given path;
  2. Try to load the grpcdebug_config.yaml file in the current working directory;
  3. Try to load the grpcdebug_config.yaml file in the user config directory (Linux: $HOME/.config, macOS: $HOME/Library/Application Support, Windows: %AppData%, see os.UserConfigDir()).

For example, we can connect to our mock test server's secure admin port via:

bash
GRPCDEBUG_CONFIG=internal/testing/grpcdebug_config.yaml grpcdebug localhost:50052 channelz channels
# Or
GRPCDEBUG_CONFIG=internal/testing/grpcdebug_config.yaml grpcdebug prod channelz channels

Health

grpcdebug can be used to fetch the health checking status of a peer gRPC application (see health.proto). gRPC's health checking works at the service-level, meaning services registered on the same gRPC server may have different health statuses. The health status of service "" is used to represent the overall health status of the gRPC application.

To simply fetch the overall health status:

bash
grpcdebug localhost:50051 health
# :  SERVING
# or
# :  NOT_SERVING

Or fetch individual service's health status:

bash
grpcdebug localhost:50051 health helloworld.Greeter
# :            SERVING
# helloworld.Greeter:   SERVING

Channelz

Channelz is a channel tracing library that allows applications to remotely query gRPC internal debug information. Also, Channelz has a web interface (see gdebug). grpcdebug is able to fetch information and present it in a more readable way.

Generally, you wil start with either the servers or channels command and then work down to the details.

Usage 1: Raw Channelz Output

For all Channelz commands, you can add --json to get the raw Channelz output.

bash
grpcdebug localhost:50051 channelz servers --json
#[
#  {
#    "ref": {
#      "server_id": 2,
#      "name": "ServerImpl{logId=2, transportServer=NettyServer{logId=1, addresses=[0.0.0.0/0.0.0.0:50051]}}"
#    },
#    "data": {
#      "calls_started": 3,
#      "calls_succeeded": 2,
#      "last_call_started_timestamp": {
#        "seconds": 1680220688,
#        "nanos": 444000000
#      }
#    },
#    "listen_socket": [
#      {
#        "socket_id": 3,
#        "name": "ListenSocket{logId=3, channel=[id: 0x05f9f16c, L:/0:0:0:0:0:0:0:0%0:50051]}"
#      }
#    ]
#  }
#]

Usage 2: List Client Channels

bash
grpcdebug localhost:50051 channelz channels
# Channel ID   Target            State     Calls(Started/Succeeded/Failed)   Created Time
# 7            localhost:10001   READY     5136/4631/505                     8 minutes ago

Usage 3: List Servers

bash
grpcdebug localhost:50051 channelz servers
# Server ID   Listen Addresses   Calls(Started/Succeeded/Failed)   Last Call Started
# 1           [:::10001]         2852/2530/322                     now
# 2           [:::50051]         29/28/0                           now
# 3           [:::50052]         4/4/0                             26 seconds ago

Usage 4: Inspect a Channel

You can identify a channel via the Channel ID.

…

Usage 5: Inspect a Subchannel

bash
grpcdebug localhost:50051 channelz subchannel 8
# Subchannel ID:     8
# Target:            localhost:10001
# State:             READY
# Calls Started:     4490
# Calls Succeeded:   3966
# Calls Failed:      524
# Created Time:      7 minutes ago
# ---
# Socket ID   Local->Remote          Streams(Started/Succeeded/Failed)   Messages(Sent/Received)
# 9           ::1:47436->::1:10001   4490/4490/0                         4490/3966

Usage 6: Inspect a Socket

…

Usage 7: Inspect a Server

bash
grpcdebug localhost:50051 channelz server 1
# Server Id:           1
# Listen Addresses:    [:::10001]
# Calls Started:       5250
# Calls Succeeded:     4647
# Calls Failed:        603
# Last Call Started:   now
# ---
# Socket ID   Local->Remote          Streams(Started/Succeeded/Failed)   Messages(Sent/Received)
# 10          ::1:10001->::1:47436   5250/5250/0                         4647/5250

Usage 8: Pagination

In production, there may be thousands of clients/servers/sockets. It would be very noisy to print all of them at once, so Channelz supports pagination through start_id and max_results

bash
grpcdebug localhost:50051 channelz servers --start_id=0 --max_results=1
# Server ID   Listen Addresses   Calls(Started/Succeeded/Failed)   Last Call Started
# 1           [:::10001]         2852/2530/322                     now
grpcdebug localhost:50051 channelz servers --start_id=2 --max_results=2
# Server ID   Listen Addresses   Calls(Started/Succeeded/Failed)   Last Call Started
# 2           [:::50051]         29/28/0                           now
# 3           [:::50052]         4/4/0                             26 seconds ago

It works similarly for printing channels via channelz channels and printing server sockets via channelz server.

Debug xDS

xDS is a data plane configuration API commonly used in service mesh projects. It's created by Envoy, used by Istio, Traffic Director, and gRPC.

Usage 1: xDS Resources Overview

The xDS resources status might be REQUESTED/DOES_NOT_EXIST/ACKED/NACKED (see config_dump.proto). This view is intended for a quick scan if a configuration is propagated from the service mesh control plane.

…

Usage 2: Dump xDS Configs

bash
grpcdebug localhost:50051 xds config
# {
#   "config":  [
#     {
#       "node":  {
#         "id":  "projects/1040920224690/networks/default/nodes/5cc9170c-d5b4-4061-b431-c1d43e6ac0ab",
#         "cluster":  "cluster",
#         "metadata":  {
#           "INSTANCE_IP":  "192.168.120.31",
#           "TRAFFICDIRECTOR_GCP_PROJECT_NUMBER":  "1040920224690",
#           "TRAFFICDIRECTOR_NETWORK_NAME":  "default"
#         },
# ...

For an example config dump, see csds_config_dump.json.

Usage 3: Filter xDS Configs

The dumped xDS config can be quite verbose, if I only interested in certain xDS type, grpcdebug can only print the selected section.

…

Admin Services

gRPC Java:

…

gRPC Go:

…

gRPC C++:

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goclidebuggogolang

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具