goaccess icon indicating copy to clipboard operation
goaccess copied to clipboard

How to use my custom log format?

Open kenw232 opened this issue 11 years ago • 20 comments

I can't figure how to get goaccess to read my log file. It says

Fatal error has occurred Error occured at: goaccess.c - main - 832 Nothing valid to process.

This is my log definition in Apache:

[%{%a %b %d %H:%M:%S %Y}t] %v:%p - %h (PID %P %Dus) %u \"%r\" %>s %b \"%{Referer}i\" \"% User-Agent}i\"

This is an example log entry from it:

[Sun Apr 05 01:14:01 2015] www.site.com:80 - 143.81.103.52 (PID 5854 40913us) - "GET /accommodations.html HTTP/1.1" 200 13242 "http://site.com/culinary.html" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; rv:11.0) like Gecko"

This is what I tried for log-format in goaccess.conf

log-format [%{%a %b %d %H:%M:%S %Y}t] %v:%p - %h (PID %P %Dus) %u "%r" %>s %b

Any idea how to get this to work?

kenw232 avatar Apr 08 '15 02:04 kenw232

The following formats should do it:

log-format [%d %t %^] %^ %^ %h %^"%r" %s %b "%R" "%u"
date-format %a %b %e 
time-format %H:%M:%S

allinurl avatar Apr 08 '15 02:04 allinurl

I can't specify time-format in goaccess.conf. It says goaccess: unrecognized option '--time-format' when I try to run it?

kenw232 avatar Apr 08 '15 18:04 kenw232

time-format was intoruced on v0.9. You may want to update or use:

log-format [%d %^] %^ %^ %h %^"%r" %s %b "%R" "%u"
date-format %a %b %e 

allinurl avatar Apr 08 '15 18:04 allinurl

Closing this. Feel free to reopen if needed.

allinurl avatar Apr 08 '15 23:04 allinurl

Just installed this tool today via brew install goaccess

I was trying to use --time-format

goaccess --version
GoAccess - 0.8.5.
For more details visit: http://goaccess.io
Copyright (C) 2009-2014 GNU GPL'd, by Gerardo Orellana

With the help of this guy https://github.com/allinurl/goaccess/issues/258#issuecomment-117190010

I also changed the original script to support my log format from iis https://gist.github.com/soheilpro/a34957550b1bd7d42be2#gistcomment-1742140

felquis avatar Apr 05 '16 02:04 felquis

My log: May 22 15:28:02 hostname process: message

What is the right regex for date time and log format. I keep getting Verify your date/time/log format error

chethanv28 avatar May 24 '17 18:05 chethanv28

@chethanv28 Is your log a web access log? e.g., nginx, apache, etc... goaccess is a web log analysis tool.

allinurl avatar May 24 '17 18:05 allinurl

syslog

chethanv28 avatar May 24 '17 18:05 chethanv28

@chethanv28 if your syslog doesn't contain access logs then you'd need a different tool to analyze it.

allinurl avatar May 24 '17 18:05 allinurl

what should be the format for my log file:

Info: 2018/02/22 13:59:06 redis.go:15: Initializing redis

Thanks

shivkumarsingh7 avatar Feb 23 '18 12:02 shivkumarsingh7

@shivkumarsingh7 your log doesn't look like a web log (access.log), you'd need a different tool to analyze it.

allinurl avatar Feb 23 '18 12:02 allinurl

Thanks @allinurl , Can you guide me how to do that?

shivkumarsingh7 avatar Feb 23 '18 12:02 shivkumarsingh7

@shivkumarsingh7 I'd suggest browsing or exploring relevant topics, e.g., analytics.

allinurl avatar Feb 23 '18 13:02 allinurl

how to name my custom format in ~/.goaccessrc ? I have customized nginx access_log, customize parser for goaccess and want to save it. May be I misread manpages, but not found this

desempare avatar Sep 09 '21 08:09 desempare

@desempare You can simply set your log format in your ~/.goaccessrc as

log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
date-format %d/%b/%Y
time-format %H:%M:%S

Take a look at this script if you need to convert an nginx format to goaccess. Also the man page.

allinurl avatar Sep 14 '21 00:09 allinurl

@desempare You can simply set your log format in your ~/.goaccessrc as

log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
date-format %d/%b/%Y
time-format %H:%M:%S

Take a look at this script if you need to convert an nginx format to goaccess. Also the man page.

Yeah, I make it already, but how to simply call my format (may be I have more than one), only write various cfg files ? Thank you

desempare avatar Sep 15 '21 14:09 desempare

I mean goaccess --log-format=myformat1 mylog.log, goaccess --log-format=myformat2 myotherlog.log, something like that.

desempare avatar Sep 15 '21 14:09 desempare

@desempare Unfortunately multiple log formats are not supported at the moment, you will need to parse them separately.

allinurl avatar Sep 20 '21 23:09 allinurl

How use goaccess with other filelog. Can i use in different format ? For example log file: Nov 27 08:22:46 kzn-mtts-br-01 KZN-MTTS-BR-01-RE1 mib2d[21987]: %DAEMON-4-SNMP_TRAP_LINK_DOWN: ifIndex 1068, ifAdminStatus up(1), ifOperStatus down(2), ifName xe-4/1/0

priscilf avatar Nov 27 '23 06:11 priscilf

@fanfaronDo, you can indeed employ various format specifiers. However, I'm uncertain about the type of log you're attempting to analyze, as it doesn't seem to be a standard access log that goaccess primarily operates with. Please provide details about the fields you intend to extract.

allinurl avatar Nov 29 '23 00:11 allinurl