Giter VIP home page Giter VIP logo

collectd-apachelog's Introduction

collectd-apachelog

Collectd plugin for obtaining request metrics from Apache's access log. Based on the apache-log-parser library and the collectd-python.

Installation & Configuration

  • Install the apache-log-parser package
  • Clone this repo: git clone https://github.com/mirekys/collectd-apachelog.git
  • Place apachelog.py to your collectd-python ModulePath
  • Update your collectd.conf
  <Plugin python>
        ModulePath "/../../collectd-plugins/" # Path, where will the apachelog.py reside
        LogTraces false
        Interactive false
        Import "apachelog"

        <Module apachelog>
                # Plugin instance name
                Name "serverX_requests"
                # Which time interval should be read from the Access_log at each plugin run
                Interval 1
                AccessLog "/etc/httpd/logs/ssl_access.log"
                # Whichever format does your Apache server use for the Access_log
                AccessLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %k %I %O %D" 
        </Module>
</Plugin>

Output

Output of the plugin is dependent mainly on the Access_log_format that you specify. It is used by the apache-log-parser which then returns specific keys & values depending on format.

Values are then aggregated by HTTP method and further into bytes, count and response time field types. The value paths provided by the plugin are built dynamically as it reads the different requests from the Access_log (there is no predetermined set of value paths).

Output example:

serverX_requests/count-GET=4
serverX_requests/count-GET-num_keepalives=3
serverX_requests/bytes-GET-bytes_tx=16017
serverX_requests/bytes-GET-bytes_rx=3679
serverX_requests/bytes-GET-response_bytes_clf=12614
serverX_requests/response_time-GET-time_us=457318
serverX_requests/count-GET-status_2xx=4
serverX_requests/count-GET-status_3xx=0

Debugging

You can run this plugin in standalone debug mode, where it outputs to console what would be otherwise sent to the collectd daemon:

./apachelog.py debug

collectd-apachelog's People

Contributors

mirekys avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

collectd-apachelog's Issues

only supports one site?

I tried to support more than one vhost log but it only seems to accept the last one:

    Import apachelog
    <Module apachelog>
        Name "site1_requests"
        Interval 1
        AccessLog "/var/log/apache2/site1-access.log"
        AccessLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
    </Module>
    <Module apachelog>
        Name "site2_requests"
        Interval 1
        AccessLog "/var/log/apache2/site2-access.log"
        AccessLogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
    </Module>

apachelog fails to re-read log after logrotate

So, I'm using apachelog to parse logs from both apache http and apache tomcat (works ok, very similar log format). At 00:00 tonight it stopped reading the tomcat log beacuse it was rotated, but the httpd log wasn't rotated so I don't know if it will fail there too.
Is there a way to make it survive logrotates?

Error Unhaldled Python Exception

I'm getting below error and notice in collectd log file. Kindly suggest.

[error] Unhandled python exception in read callback: LineDoesntMatchException: LineDoesntMatchException(log_line="LOGS xxx xxx xxx xxx")

[notice] read-function of plugin `python.apachelog' failed. Will suspend it for 640.000 seconds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.