rmedvedev / grpcdump

Tool for capture and parse grpc traffic
MIT License
154 stars 23 forks source link

how to output grpc messages #4

Closed jschwinger233 closed 3 years ago

jschwinger233 commented 4 years ago

I looked into grpcdump -h but failed to figure out how to print messages after trying -log-level debug -assembly_debug_log, could you please share some insights?

What I want is just like tcpdump -A that prints every byte in ascii; since grpc uses structural messages instead of bytes I feel like capturing all messages.

rmedvedev commented 4 years ago

Hi, the main feature of this tool is parsing grpc traffic using proto files. Now grpcdump does not support prints bytes of grpc messages. I think this feature is needed and i will do it soon.

jschwinger233 commented 3 years ago

I just figured it out that it's already there!

# ./main -i enp2s0f0 -p 5001 -proto-files core.proto  -proto-path $(pwd) -json | jq

INFO[0000] Starting sniff ethernet packets at interface enp2s0f0 on port 5001
{
  "src": "10.22.12.88:25284",
  "dst": "10.22.12.87:5001",
  "path": "/pb.CoreRPC/CreateWorkload",
  "body": "name:\"zc\" entrypoint:<name:\"zc\"> podname:\"local\" image:\"harbor.shopeemobile.com/cloud/bash\" count:1 deploy_strategy:FILLGLOBAL resource_opts:<cpu_quota_limit:0.1 memory_limit:100000000>",
  "headers": {
    ":authority": "10.22.12.87:5001",
    ":method": "POST",
    ":path": "/pb.CoreRPC/CreateWorkload",
    ":scheme": "http",
    "content-type": "application/grpc",
    "te": "trailers",
    "user-agent": "grpcurl/dev-build (no version set) grpc-go/1.35.0-dev"
  }
}
{
  "src": "10.22.12.87:5001",
  "dst": "10.22.12.88:25284",
  "path": "",
  "body": "error:\"not enough nodes\" resource:<>",
  "headers": {
    ":status": "200",
    "content-type": "application/grpc",
    "grpc-message": "",
    "grpc-status": "0"
  }
}

The body field over there is all I needed, and the key to get it correct is just specifying -proto-path and -proto-file together, I specified only -proto-file before!

Thank you very much for your effort, this saves my life!