You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[feature request] Parsing 1 JSON Blob per line (log analysis) #638
@wycats that won't work as from-json will collect the lines. The suggestion here, I think, is to have two modes for converting files. Sometimes, as when you're working with stdout from an external command, you want to collect up all the lines before you do conversion. Other times, you may want to do what the author here requests, which is to operate over the lines individually.
@rrichardson I guess this is what you were asking. The flag is --objects, should we rename it to --per-line (as @jonathandturner suggested before) @wycats ?
So this works for open but not for piping from stdout? What is the disconnect there?
(I just tested this trying to pipe from my log source and it hung)
kubectl logs mysvc | from-json --objects
^C
thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/9eae1fc0ea9b00341b8fe191582c4decb5cb86a3/src/libcore/slice/mod.rs:2715:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
@rrichardson It should work for piping from stdout. Please, could you file a new issue with your message and, if you can, also paste the output from kubectl logs mysvc ?
@androbtech - Actually, it's not as bad as I first thought. I had some non-json lines in the log. I filtered past those and | from-json --objects worked.
There is still an issue, though, and that is if JSON parsing fails, the operation hangs.
Activity
wycats commentedon Sep 10, 2019
Can you pipe to
lines?sophiajt commentedon Sep 10, 2019
@wycats that won't work as from-json will collect the lines. The suggestion here, I think, is to have two modes for converting files. Sometimes, as when you're working with stdout from an external command, you want to collect up all the lines before you do conversion. Other times, you may want to do what the author here requests, which is to operate over the lines individually.
andrasio commentedon Sep 10, 2019
@rrichardson As a workaround, save your output to
file.txtlike so:Followed by
open file.txt | from-json --objectsIt should work equally well if you pipe your output as long as each line is a string json object and you are using
--objectsflag forfrom-jsonandrasio commentedon Sep 10, 2019
@rrichardson I guess this is what you were asking. The flag is
--objects, should we rename it to--per-line(as @jonathandturner suggested before) @wycats ?What do you think? @rrichardson
rrichardson commentedon Sep 10, 2019
--per-lineis more clear to me than--objectsSo this works for
openbut not for piping from stdout? What is the disconnect there?(I just tested this trying to pipe from my log source and it hung)
andrasio commentedon Sep 10, 2019
@rrichardson It should work for piping from stdout. Please, could you file a new issue with your message and, if you can, also paste the output from
kubectl logs mysvc?andrasio commentedon Sep 10, 2019
@rrichardson also paste the output when running with
RUST_BACKTRACE=1if you can. Thank you!rrichardson commentedon Sep 10, 2019
@androbtech - Actually, it's not as bad as I first thought. I had some non-json lines in the log. I filtered past those and
| from-json --objectsworked.There is still an issue, though, and that is if JSON parsing fails, the operation hangs.
rrichardson commentedon Sep 10, 2019
I have updated #514 , it seemed close enough
#514 (comment)
Add parser tracing, fix 629 (nushell#638)
Add parser tracing, fix 629 (#638)
Update working_with_lists.md (nushell#638)