Parsing single line JSON log


Author
Message
MBecer
MBecer
New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)
Group: Forum Members
Posts: 2, Visits: 3
Hi,
I regularly receive log files, which contain a set of JSON entries, but unfortunately, these entries are all in a singe line, separated by tab instead of line break.
The JSON parser works fine, once i "manually" replace all \t with \n outside of LogView, but I'd like to not do this at all and just load the files. Is there an easy way to achieve this, without the need to write a custom reader (or does someone already have such a parser i can get?).
Once broken up into several lines, this Json Parser works fine for me:
{
    "time": "%d{yyyy-MM-ddT%H:mm:ss.fffffffffZ}",
    "stream": "%S{stream}",
    "_p": "%S{_p}",
    "log": "%S{log}",
    "kubernetes": {
        "pod_name": "%S{pod_name}",
        "namespace_name": "%S{namespace_name}",
        "pod_id": "%S{pod_id}",
        "host": "%S{host}",
        "container_name": "%S{container_name}",
        "docker_id": "%S{docker_id}",
        "container_hash": "%m",
        "container_image": "%S{container_image}"
    }
}
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
Hi MBecer,

LogViewPlus is build to tail log files.  It does this by attempting to read a log file line by line.

It sounds like your JSON log is actually one big JSON file, so the tail feature would never be used.  All of the objects are written at once and there is no need to separate them out line by line.

If this is not the case, it may help if I could see a few sample log entries.

In this case your 'manual' solution is probably best.  I would suggest replacing the tabs with new lines using a script or batch file and running that command before opening the file.

Hope that helps,

Toby
MBecer
MBecer
New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)New Member (4 reputation)
Group: Forum Members
Posts: 2, Visits: 3
Thanks!
Took some time but worked perfectly!
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
Glad that helped - thanks for letting me know!  :-)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Login

Explore
Messages
Mentions
Search