Skip to content

Commit a28e154

Browse files
committed
Update documents to reflect the latest changes
Signed-off-by: Liu Lantao <[email protected]>
1 parent 47fc475 commit a28e154

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

README.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
# About
22

3-
Monitor the incoming and outgoing traffic metrics in realtime for NGINX http subsystem.
3+
Monitor the incoming and outgoing traffic metrics in realtime for `NGINX` http subsystem.
44

55
Realtime traffic and status code monitor solution for NGINX, need less memory and cpu than realtime log analyzing.
66
Useful for http traffic accounting based on NGINX config logic ( by-location or by-server or by-user-defined-variable ).
77

8+
## Why?
9+
10+
Real-time log analysis solution,
11+
which requires multiple machines for storage and analysis,
12+
are too heavy for application monitoring.
13+
14+
An cost-effective solution is needed to monitor the traffic metrics/status of application requests.
15+
That solution should be accurate, sensitive, robust, light weight enough, and not affected by traffic peaks.
16+
17+
## How it works?
18+
19+
The context of this module keeps a list of **metrics** identified by `accounting_id`.
20+
21+
When a new **request** hits the server, the module will try to find its `accounting_id`, calculate statistics, and **aggregate** them into the corresponding metrics.
22+
23+
For every period (defined by `interval`), a timer event is triggered, these metrics are rotated and exported to log files or remote log servers.
24+
25+
---
26+
827
# Installation
928
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FLax%2Fnginx-http-accounting-module.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FLax%2Fnginx-http-accounting-module?ref=badge_shield)
1029

@@ -65,12 +84,19 @@ http_accounting
6584

6685
http_accounting_log
6786
--------------------
68-
**syntax:** *http_accounting_log \</path/to/log/file>*
87+
**syntax:** *http_accounting_log \</path/to/log/file> \[level]*
6988

7089
**default:** *-*
7190

7291
**context:** *http*
7392

93+
Configures logging.
94+
Support both local `file` path, or `stderr`, or `syslog:`.
95+
The second parameter is the log level.
96+
For more details of supported params, refer to [this page from nginx.org](http://nginx.org/en/docs/ngx_core_module.html#error_log).
97+
98+
If not specified, accounting log will be written to `/dev/log`.
99+
74100
http_accounting_id
75101
--------------------
76102
**syntax:** *http_accounting_id \<accounting_id>*
@@ -79,9 +105,8 @@ http_accounting_id
79105

80106
**context:** *server, location, if in location*
81107

82-
Specifies current request belongs to which accounting_id.
83-
84-
This directive was first introduced in the v0.1 release, and can use variable in v1.0 and above.
108+
Sets the `accounting_id` string by user defined variable.
109+
This string is used to determine which `metrics` a request/session should be aggregated to.
85110

86111
http_accounting_interval
87112
------------------------
@@ -105,11 +130,14 @@ Randomly staggers the reporting interval by 20% from the usual time.
105130

106131
# Usage
107132

108-
This module writes statistics to syslog. You should edit your syslog configuration.
133+
This module can be configured to writes statistics to local file, remote log server or local syslog device.
134+
135+
To collect logs with syslog,
136+
refer [Lax/ngx_http_accounting_module-utils](http://github.com/Lax/ngx_http_accounting_module-utils) to for sample configuration / utils.
109137

110-
For sample configuration / utils, see: [Lax/ngx_http_accounting_module-utils](http://github.com/Lax/ngx_http_accounting_module-utils)
138+
Some open-source log-aggregation software such as logstash also support syslog input, which will help you establish a central log server.
111139

112-
## Sample syslog output
140+
## Metrics log format
113141

114142
Apr 8 11:19:46 localhost NgxAccounting: pid:8555|from:1428463159|to:1428463186|accounting_id:default|requests:10|bytes_in:1400|bytes_out:223062|latency_ms:1873|upstream_latency_ms:1873|200:9|302:1
115143

@@ -119,18 +147,18 @@ The output contains a list of k/v for the accounting metrics, in the sequence of
119147
|------------------|----------|
120148
| `pid` | pid of nginx worker process |
121149
| `from` / `to` | metric was collected between these timestamps |
122-
| `accounting_id` | identify for the accounting unit, you name it with `http_accounting_id` directive |
123-
| `requests` | count of total requests processed |
150+
| `accounting_id` | identify the accounting unit, set with `http_accounting_id` directive |
151+
| `requests` | count of total requests processed in current period |
124152
| `bytes_in` | total bytes receiverd by the server |
125153
| `bytes_out` | total bytes send out by the server |
126-
| `latency_ms` | a sum of `$request_time`, in `millisecond` |
127-
| `upstream_latency_ms` | a sum of `$upstream_response_time`, in `millisecond` |
128-
| `200` / `302` / `400` / `404` / `500` ... | count of requests which response is with http code `200`/`302`/`400`/`404`/`500`, etc |
154+
| `latency_ms` | sum of `$request_time`, in `millisecond` |
155+
| `upstream_latency_ms` | sum of `$upstream_response_time`, in `millisecond` |
156+
| `200` / `302` / `400` / `404` / `500` ... | count of requests with http status code `200`/`302`/`400`/`404`/`500`, etc |
129157

130158
# Branches
131159

132-
* master : new feathers
133-
* v2-freeze-20110526 : works with nginx version(0.7.xx, 0.8.xx), nginx 0.9 is not tested. didn't work with nginx above 1.0.x.
160+
* master : main development branch.
161+
* v2-freeze-20110526 : legacy release. works with nginx version(0.7.xx, 0.8.xx), nginx 0.9 is not tested. didn't work with nginx above 1.0.x.
134162

135163
# Contributing
136164

0 commit comments

Comments
 (0)