Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing JSON with GoAccess #535

Closed
konungrl opened this issue Oct 10, 2016 · 3 comments
Closed

Parsing JSON with GoAccess #535

konungrl opened this issue Oct 10, 2016 · 3 comments
Labels

Comments

@konungrl
Copy link

Greetings, sir. Could you please help me with parsing json log file.
Example of log string:

{"ip": "176.122.232.00", "host": "cdn.tv.com", "path": "/dtv/c_1199622700411804.ts", "status": "200", "user_agent": "YX_XY/1.0.1.0.3364", "length": 1392120, "date": "2016-10-09T20:00:00+03:00"}

I'm using this format:
goaccess -f access.log --log-format='%^: "%h", %^:%^, %^: "%R", %^: %s, %^: "%u",%^: %b, %^: "%dT%t+%^"' --date-format='%Y-%m-%d' > /report.html

And getting

Parsing... [1 734 743] [867 371/s]s]
GoAccess - version 0.8.5 - Dec  5 2014 06:36:01
Fatal error has occurred
Error occured at: goaccess.c - main - 832
Nothing valid to process

What's wrong with my log-format?
Thanks.

@allinurl
Copy link
Owner

This should work:

goaccess -f access.log --log-format='%^: "%h",%^: "%v",%^: "%U",%^: "%s",%^: "%u",%^: %b,%^: "%dT%t+%^"%^' --date-format='%Y-%m-%d' --time-format='%T' --http-protocol=no --http-method=no

@konungrl
Copy link
Author

Thanks for reply,
I've got this errors
goaccess: unrecognized option '--time-format=%T' (probably i have new version)

Then i removed option time-format and got 2 more errors.

goaccess: option '--http-protocol' doesn't allow an argument
goaccess: option '--http-method' doesn't allow an argument

When i removed all of this options i finally got my report.
By the way, could you please explain this log format for the for the further generations? :)

@allinurl
Copy link
Owner

allinurl commented Oct 10, 2016

For those unrecognized options, please upgrade to the latest version.

Great question, one of the most important parts in the log format is the character that follows %^ or any other specifier. The parser will look for that character, so for instance, if I have %^:, it means that I want the parser to skip everything until a : is found. That helps a lot so I don't have to use a bunch of %^ to ignore fields. The upcoming version, will handle this better by displaying which tokens did not match the log format, which should make things easier.

For a list of available log specifiers, please take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants