Closed pratikmallya closed 4 years ago
Thanks @pratikmallya. Just to help me understand your use case – if you don't put in the -n +2
flag to tail
, will jq
blow up?
if you don't put in the -n +2 flag to tail, will jq blow up?
Yep:
logdna search "QUERY" -j | jq
parse error: Invalid numeric literal at line 1, column 7
A typical recourse here is to send the informational output to stderr while the core output remains on stdout. This is what things like curl and tar do.
To chime in, occasionally I've seen 0 logs returned on some search queries. For which the empty result message is also output to stdout. It'd be good to have a separate exit code and the msg to stderr for such cases when using the raw json option.
search finished: 0 line(s). hosts: all. apps: all. levels: all. tags: all. query: <some-query>
Query returned no lines.
This is great feedback – thanks @joshk0 and @navyapothineni. Sitting down today to hash out an appropriate solution.
Thanks. PR #43 will close this issue.
@pratikmallya, this has been added/fixed in the newest v2
release which is available to be used. Please, let us know if you have any other additional comments!
Currently, when attempting to do a search, the first line summarizes the findings:
This makes it hard to use the cli as part of unix pipelines. e.g. I would like to use
jq
to parse the logs into a more human friendly log, but that's not possible (well it is if one uses tail e.g.logdna search "QUERY" -j | tail -n +2| jq .
)To be effective as a cli tool, I would expect the
raw json
output to give a truly raw json response sotail
does not have to be used.