ziti-tunnel-sdk-c
ziti-tunnel-sdk-c copied to clipboard
tunnel_status output is not valid JSON
ziti-edge-tunnel has both human and machine-readable troubleshooting outputs that may be accessed by separate sub-commands:
dumpsends a human readable status dump to stdouttunnel_statusproduces 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"
]
do you know if this behavior was introduced with 0.19.10?
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.
This issue relates to https://github.com/openziti/ziti-tunnel-sdk-c/issues/484
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
+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.
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
The output is currently formatted as invalid JSON. The request is to make it valid.
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