Giter VIP home page Giter VIP logo

Comments (3)

Lax avatar Lax commented on July 17, 2024 1

The accounting_log directive supports adding a log output to remote central syslog server with UDP or TCP protocol.

See here for an example: https://github.com/Lax/traffic-accounting-nginx-module/blob/master/samples/http.conf#L6

The support parameters are the same as Nginx logging directives: https://nginx.org/en/docs/syslog.html

On the central syslog server, you can receive and save the logs with a normal syslog implement(rsyslog, syslog-ng),
or use any other logging server such as logstash, to receive and process the logs.
See an example in this folder: https://github.com/Lax/traffic-accounting-nginx-module/tree/master/samples


                      syslog(UDP)
NGINX -----------------------> syslogd / logstash / or your own UDP server

from traffic-accounting-nginx-module.

venomone avatar venomone commented on July 17, 2024

Do you maybe have an example on how to log looks like in the end? I want to parse the used bandwidth per WebDAV User. Thanks in advance

from traffic-accounting-nginx-module.

Lax avatar Lax commented on July 17, 2024

The final log looks like this:

# HTTP
2018/05/14 14:18:18 [notice] 5#0: pid:5|from:1526278638|to:1526278659|accounting_id:HTTP_ECHO_HELLO|requests:4872|bytes_in:438480|bytes_out:730800|latency_ms:0|upstream_latency_ms:0|200:4872
2018/05/14 14:18:18 [notice] 5#0: pid:5|from:1526278638|to:1526278659|accounting_id:INDEX|requests:4849|bytes_in:421863|bytes_out:1857167|latency_ms:0|upstream_latency_ms:0|301:4849

# Stream
2018/05/14 14:18:22 [notice] 5#0: pid:5|from:1526278642|to:1526278659|accounting_id:TCP_PROXY_ECHO|sessions:9723|bytes_in:860343|bytes_out:2587967|latency_ms:4133|upstream_latency_ms:3810|200:9723

In the NGINX config file, use accounting_log, let the result transfer to a syslog: target. It's similar to error_log of NGINX (reference)

accounting_log  syslog:server=192.168.1.1:29124  ;

I was using logstash to collect the log, find the config file here

from traffic-accounting-nginx-module.

Related Issues (20)

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.