cmd: add output options for cilium monitor#1112
Conversation
By default, when `cilium monitor` is ran, a one-line summary will be output, only for drop and capture messages. A new flag, -v for verbose, is added which will output more detailed information about each packet for debug, drop, and capture messages, which was before the default behavior for `cilium monitor`. Signed-off by: Ian Vernon <ian@covalent.io>
Signed-off-by: Thomas Graf <thomas@cilium.io>
TCP forwarding: <- endpoint 64189, identity 258: 10.15.220.6:51198 -> 10.15.242.54:80 tcp SYN -> ifindex 586: 10.15.220.6:51198 -> 10.15.242.54:80 tcp SYN <- endpoint 33115, identity 257: 10.15.242.54:80 -> 10.15.220.6:51198 tcp ACK, RST -> endpoint 64189, identity 258: 10.15.242.54:80 -> 10.15.220.6:51198 tcp ACK, RST ARP: <- endpoint 33115, identity 257: ea:e1:ad:23:9e:ac -> 1e:19:55:1b:27:a0 ARP -> endpoint 33115, identity 257: 1e:19:55:1b:27:a0 -> ea:e1:ad:23:9e:ac ARP <- endpoint 64189, identity 258: 62:28:3d:b9:16:71 -> ba:15:0d:5c:cb:90 ARP -> endpoint 64189, identity 258: ba:15:0d:5c:cb:90 -> 62:28:3d:b9:16:71 ARP ICMP forwarding: <- endpoint 50098: 10.15.189.46 -> 10.15.222.137 EchoReply -> endpoint 42392: 10.15.189.46 -> 10.15.222.137 EchoReply <- endpoint 42392: 10.15.222.137 -> 10.15.189.46 EchoRequest -> endpoint 50098: 10.15.222.137 -> 10.15.189.46 EchoRequest <- endpoint 50098: 10.15.189.46 -> 10.15.222.137 EchoReply -> endpoint 42392: 10.15.189.46 -> 10.15.222.137 EchoReply Drops: <- endpoint 64189, identity 257: 10.15.220.6 -> 10.15.247.232 EchoRequest xx drop (Policy denied) to endpoint 29898, identity 257->256: 10.15.220.6 -> 10.15.247.232 EchoRequest <- endpoint 64189, identity 257: 10.15.220.6 -> 10.15.247.232 EchoRequest xx drop (Policy denied) to endpoint 29898, identity 257->256: 10.15.220.6 -> 10.15.247.232 EchoRequest Signed-off-by: Thomas Graf <thomas@cilium.io>
Require user to provide --hex flag to disabled decoding and printing in hexadecimal format. Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Thomas Graf <thomas@cilium.io>
Allow to disable basic tracing with --disable-trace agent flag Signed-off-by: Thomas Graf <thomas@cilium.io>
Add --trace-payloadlen option to set length of captured payload Signed-off-by: Thomas Graf <thomas@cilium.io>
| return fmt.Sprintf("%d", reason) | ||
| } | ||
|
|
||
| func (n *DropNotify) DumpInfo(data []byte) { |
There was a problem hiding this comment.
exported method DropNotify.DumpInfo should have comment or be unexported
| // data | ||
| } | ||
|
|
||
| func (n *DebugCapture) DumpInfo(data []byte) { |
There was a problem hiding this comment.
exported method DebugCapture.DumpInfo should have comment or be unexported
| type Verbosity uint8 | ||
|
|
||
| const ( | ||
| INFO Verbosity = iota + 1 |
There was a problem hiding this comment.
exported const INFO should have comment (or a comment on this block) or be unexported
9cc1a81 to
715f502
Compare
Yes! This is exactly on the right track. I think we can find a better wording. |
|
@tgraf how about "SENDING" or "FORWARDING"? |
We have 4 main actions:
Maybe something like this?
|
|
OK, I went through the DebugMessage types and pulled out the ones I thought were relevant to what you mentioned above, and reformatted the others accordingly. Currently not all of what you want above is achievable as part of this first pass at this issue (i.e., getting the IPs from the various message types) - it will be once I add more rich metadata as we discussed by querying the API. Let's discuss further on Slack if this isn't what you are looking for so I can nail down the requirements. This is what the monitor looks like when ran against the |
| } | ||
|
|
||
|
|
||
| func (n *DebugMsg) DumpInfo(data []byte) { |
There was a problem hiding this comment.
exported method DebugMsg.DumpInfo should have comment or be unexported
There was a problem hiding this comment.
if block ends with a return statement, so drop this else and outdent its block
There was a problem hiding this comment.
var addTcpFlag should be addTCPFlag
|
Looks good but will need a rebase. It will conflict due to my BPF changes so |
7911cfa to
f797571
Compare
aalemayhu
left a comment
There was a problem hiding this comment.
Overall this is an improvement but looking at the output this seems rushed IMO. For example the filter output now looks weird (sudo ./cilium/cilium monitor --type debug -v).
| // DumpInfo https://techcrunch.com/2017/07/12/soundshroud/ | ||
| func (n *DropNotify) DumpInfo(data []byte) { | ||
| fmt.Printf("xx drop (%s) to endpoint %d, identity %d->%d: %s\n", | ||
| dropReason(n.SubType), n.DstID, n.SrcLabel, n.DstLabel, |
There was a problem hiding this comment.
Why is this prefixed xx?
There was a problem hiding this comment.
It indicates a dropped packet
This is to make sure that we can dynamically replace the value of pod namespace label (e.g. io.kubernetes.pod.namespace) to the value passed in CLI flag (e.g. --test-namespace). Related: cilium#1112 Signed-off-by: Tam Mach <tam.mach@cilium.io>
By default, when
cilium monitoris ran, a one-line summary will be output, only for drop and capture messages.A new flag, -v for verbose, is added which will output more detailed information about each packet for debug, drop, and capture messages, which was before the default behavior for
cilium monitor.Signed-off by: Ian Vernon ian@covalent.io