#213 LogFormat: match literal content

open
nobody
None
1
2015-07-31
2015-07-13
No

Hi Laurent,

I've created a patch that allows literal strings in LogFormat. It is available here:
http://source.a2o.si/patches/awstats-7.3-logformat-match-literal.diff

Reason:
I have quite extended log format and I have data prefixed with short field names which make manual looking at log file more pleasant - more readable.

The problem with AWStats is that ATM it has no way to match custom strings that are attached to content fields in LogFormat. This patch adds this ability.

My LogFormat in apache:
LogFormat "%{%Y-%m-%dT%H:%M:%S%z}t r=%a l=%A tls=0 proto=%H vh=%V vhc=%v time=%D st=%>s bytes=%O keep=%k conn=%X \"%r\" \"%{Referer}i\" \"%{User-Agent}i\"" custom-default-notls

Sample log entry produced:
2015-07-13T23:26:27+0000 r=2a01:260:1010:1010::130 l=2a01:260:1010:1010::144 tls=1 proto=HTTP/1.1 vh=vhost.teon.si vhc=vhost.teon.si time=6783 st=302 bytes=5993 keep=0 conn=- "GET / HTTP/1.1" "-" "check_http/v2.0.3 (nagios-plugins 2.0.3)"

Caveat:
This patch is simple and only allows matching literal content, if it is located as prefix to field value. For example:
- "bytes=%bytesd" works if entry in logfile is "bytes=1234".
- "size=%bytesdB" would not work, as %bytesd is not explicitly defined in awstats. It is only defined as regex %bytesd$, which is not easy to convert for my purpose, even if log entry would be is syntactically correct in this case "size=1234B" (according to LogFormat apache directive).

I can provide a git pull request for this, if requested.

What do you think?

b.

Related

Patches: #213

Discussion

  • Laurent Destailleur (Eldy)

    Yes please, can you send a PR ?

    2015-07-14 1:36 GMT+02:00 Boštjan Škufca bostjanskufca@users.sf.net:


    [patches:#213] LogFormat: match literal content

    Status: open
    Group:
    Created: Mon Jul 13, 2015 11:36 PM UTC by Boštjan Škufca
    Last Updated: Mon Jul 13, 2015 11:36 PM UTC
    Owner: nobody

    Hi Laurent,

    I've created a patch that allows literal strings in LogFormat. It is
    available here:
    http://source.a2o.si/patches/awstats-7.3-logformat-match-literal.diff

    Reason:
    I have quite extended log format and I have data prefixed with short field
    names which make manual looking at log file more pleasant - more readable.

    The problem with AWStats is that ATM it has no way to match custom strings
    that are attached to content fields in LogFormat. This patch adds this
    ability.

    My LogFormat in apache:
    LogFormat "%{%Y-%m-%dT%H:%M:%S%z}t r=%a l=%A tls=0 proto=%H vh=%V vhc=%v
    time=%D st=%>s bytes=%O keep=%k conn=%X \"%r\" \"%{Referer}i\"
    \"%{User-Agent}i\"" custom-default-notls

    Sample log entry produced:
    2015-07-13T23:26:27+0000 r=2a01:260:1010:1010::130
    l=2a01:260:1010:1010::144 tls=1 proto=HTTP/1.1 vh=vhost.teon.si vhc=
    vhost.teon.si time=6783 st=302 bytes=5993 keep=0 conn=- "GET / HTTP/1.1"
    "-" "check_http/v2.0.3 (nagios-plugins 2.0.3)"

    Caveat:
    This patch is simple and only allows matching literal content, if it is
    located as prefix to field value. For example:
    - "bytes=%bytesd" works if entry in logfile is "bytes=1234".
    - "size=%bytesdB" would not work, as %bytesd is not explicitly defined in
    awstats. It is only defined as regex %bytesd$, which is not easy to convert
    for my purpose, even if log entry would be is syntactically correct in this
    case "size=1234B" (according to LogFormat apache directive).

    I can provide a git pull request for this, if requested.

    What do you think?

    b.


    Sent from sourceforge.net because you indicated interest in <
    https://sourceforge.net/p/awstats/patches/213/>

    To unsubscribe from further messages, please visit <
    https://sourceforge.net/auth/subscriptions/>

    --
    EMail: eldy@destailleur.fr
    Web: http://www.destailleur.fr


    Google+: https://plus.google.com/+LaurentDestailleur/
    Facebook: https://www.facebook.com/Destailleur.Laurent
    Twitter: http://www.twitter.com/eldy10


     

    Related

    Patches: #213


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks