ziti-tunnel-sdk-c icon indicating copy to clipboard operation
ziti-tunnel-sdk-c copied to clipboard

tunnel_status output is not valid JSON

Open qrkourier opened this issue 3 years ago • 8 comments

ziti-edge-tunnel has both human and machine-readable troubleshooting outputs that may be accessed by separate sub-commands:

  • dump sends a human readable status dump to stdout
  • tunnel_status produces a JSON status

However, stdout is not pure JSON but is corrupted by some verbose messages that could be hidden when log level is less than DEBUG. Alternatively, the non-JSON messages could be sent to stderr. Either way, I would be able to parse stdout as JSON.

With 0.19.10 I need to trim the first 90B and the last 2B to enjoy valid JSON.

❯ /opt/openziti/bin/ziti-edge-tunnel tunnel_status|tail -c +90|head -c -2|jq keys
[
  "Code",
  "Data",
  "Success"
]

qrkourier avatar Sep 21 '22 18:09 qrkourier

do you know if this behavior was introduced with 0.19.10?

scareything avatar Sep 21 '22 18:09 scareything

I don't have a reason to suspect it was just introduced in the latest release, but wanted to note for which version this is the case. I hadn't used the tunnel_status command previously.

qrkourier avatar Sep 21 '22 18:09 qrkourier

This issue relates to https://github.com/openziti/ziti-tunnel-sdk-c/issues/484

qrkourier avatar Nov 15 '22 23:11 qrkourier

The format of the garbage output has changed in the intervening months. The new workaround is to truncate the first 20 bytes instead of 90 bytes.

❯ ziti-edge-tunnel tunnel_status|tail -c +20|head -c -2|jq '.Data.Identities[].Identifier'
"/opt/openziti/etc/identities/mfa2.json"
"/opt/openziti/etc/identities/edge-client-ken-ziti-stack.json"
"/opt/openziti/etc/identities/mattermost.json"
"/opt/openziti/etc/identities/bastion1.json"
"/opt/openziti/etc/identities/edge-client.json"
"/opt/openziti/etc/identities/miniziti-client.json"
"/opt/openziti/etc/identities/oryp4.haus.qrk.us.json"
"/opt/openziti/etc/identities/zeds-test-oryp4.json"

Alternatively, this produces valid JSON.

ziti-edge-tunnel tunnel_status | sed -E 's/(^received\sresponse\s<|>$)//g' | jq

qrkourier avatar Apr 10 '23 18:04 qrkourier

+1 on fixing the tunnel status to be pure JSON. Lots of useful monitoring applications if this is JSON, but hard to work with with the mixed data types.

mguthrie88 avatar Nov 20 '23 15:11 mguthrie88

I'm happy to see a flag added to emit only json like our other tooling does. the default command should still be formatted for humans

dovholuknf avatar Nov 20 '23 16:11 dovholuknf

The output is currently formatted as invalid JSON. The request is to make it valid.

qrkourier avatar Nov 20 '23 17:11 qrkourier

i understood what the request was. i was making my opinion clear that the command should be useful for humans without a flag, and json with a flag like our other tooling does

dovholuknf avatar Nov 20 '23 17:11 dovholuknf