Log Analyzer agent¶
To make full use of NGX Ops features and log exploitation, you need to deploy the Log Analyzer Agent.
The agent is written in Go: it uses about 40% less memory than the old Node version, which is no longer published. It runs in a container separate from NGX Ops. It watches the Nginx log files in real time, analyzes the requests and sends information and alerts to the dashboard.
The agent notably enables the following features:
- Log analysis: detection of unusual or potentially malicious behavior from various rules, such as repeated authentication attempts, scans, floods or some scraping activity.
- Volumetric analysis: detection of unusual variations in traffic volume per virtual host. The analysis notably accounts for traffic seasonality to limit false positives.
- Per-country traffic analysis: detection of an unusual increase in traffic coming from a given country.
- WAF log analysis: when you use an Nginx version that includes the WAF, such as the WAF or Coraza variants, the agent can also use the logs it generates.
- Real-time traffic display: requests can be viewed in real time on the dashboard map.
- Periodic summaries: the collected and analyzed data is used to generate periodic summaries of reverse proxy activity.
Volumetric analysis needs a learning period to determine the usual traffic behavior. The agent notably uses a baseline per time slot of the week and recommends about three weeks of observation before considering the first volumetric alerts reliable.
The Log Analyzer Agent must have read access to the log files generated by Nginx. It runs independently of the NGX Ops container and communicates with it through its API.
Deploy and configure the Log Analyzer Agent¶
Deploy the agent¶
Deployment and configuration of the Log Analyzer Agent are done directly from NGX Ops.
Configure the agent¶
Go to: ADMINISTRATION → Configuration → Log analyzer
In the input area, enter the agent configuration. Here is an example:
enable: true
host_logs_path: /containers/nginx/nginx/logs
host_data_path: /containers/nginx/config/analyzer
host_geoip_path: /containers/nginx/geoip_data
💡 Tip: Parameters that are paths must contain the absolute paths on the host. They are used to configure the Docker bind mounts the agent needs to work.
Then click Save.
Start the agent¶
Once the configuration is saved, go to: INTEGRATIONS → Analysis
Then click the Start button.
NGX Ops then creates and starts the Log Analyzer Agent container with the provided configuration.
Once the agent is started, it begins watching the Nginx logs and the collected data can be used by the different analysis features of NGX Ops.
analyzer.yml settings¶
File config/analyzer.yml, editable from ADMINISTRATION → Configuration.
| Key | Default | Role |
|---|---|---|
enable |
false |
Enables the agent |
container_image |
suite's analyzer-agent-go image |
Container image |
container_name |
ngx-analyzer |
Container name |
port |
9100 |
Agent API port, internal to the Docker network |
host_logs_path |
— | Host path of the Nginx logs |
host_data_path |
— | Host path of the agent data (history, learned baseline, rules). Required so the container can be recreated automatically without losing its state |
host_geoip_path |
— | Host path of the GeoIP databases |
log_pattern |
shipped pattern | Regular expression of the tracked log files: one file per vhost (site.fr.access.log) or the shipped shared file (vhosts_access.log) |
bruteforce_min_failures |
15 |
Brute force rule threshold |
scan_min_requests |
40 |
Scan rule threshold |
flood_min_requests |
600 |
Flood rule threshold |
ignore_status |
empty | HTTP codes ignored by all rules, for example 444 or 444,403. They are still counted in the statistics |
learning_days |
21 |
Volumetric analysis learning period |
sigma_threshold |
6 |
Volumetric analysis sensitivity |
notify_min_severity |
medium |
Minimum severity sent by email |
alert_retention_days |
90 |
Alert retention |
shipper_url |
empty | Sending alerts to the log store through the local shipper, for example http://ngx-shipper:9181 |
waf_log_pattern |
shipped pattern (*.waf.log) |
Regular expression of ModSecurity audit logs, one file per vhost, in JSON format |
waf_retention_days |
60 |
WAF data retention |
The deliberately high thresholds avoid a detector that "cries wolf". Adjust them based on your alerts rather than lowering them on principle.
The rule_*_enable keys (bruteforce, scan, flood, scraping, volumetric, country_traffic) are only used at the very first start. After that the agent remembers the activation of each rule itself: change it from the Rules button of the Analysis page.
For alerts to be sent by email, the analyzer_alert section of notifications.yml must be enabled with recipients: see Notifications and events.
ModSecurity audit logs¶
ModSecurity audit logs must be in JSON format (SecAuditLogFormat JSON), one file per vhost. The native multi-part format is not supported: it has no schema that is stable from one version to the next.
SecAuditEngine RelevantOnly
SecAuditLogParts ABIJDEFHZ
SecAuditLogType Serial
SecAuditLogFormat JSON
SecAuditLog /var/log/nginx/<vhost>.waf.log
This data has its own view in the dashboard, without notification. For a WAF that does not depend on Nginx, see the emulated WAF.
Memory, performance and maintenance¶
Measurements on identical logs, with the old Node version for comparison:
| Load | Node | Go |
|---|---|---|
| 20,000 lines, 20,000 IPs | 131 MB | 82 MB |
| 300,000 lines, 50,000 IPs | 297 MB | 176 MB |
Three environment variables specific to the Go agent are set in the container:
| Variable | Role |
|---|---|
GOGC |
Garbage collector memory/CPU trade-off (40 by default) |
GOMEMLIMIT |
Soft memory cap, for example 256MiB. Do not set it below the volume actually used |
TZ |
Time zone: the weekly baseline of the volumetric analysis is computed in local time |
The agent's SQLite databases are compacted at startup when free space justifies it, then maintained every 6 hours. With Redis, statistics being aggregated survive a restart.
Migrate from the old Node image¶
If container_image still points to the Node image (nginx-analyzer), the dashboard keeps working but shows a warning. Migration is a simple image change:
- Replace
container_imagewith theanalyzer-agent-goimage. - The dashboard recreates the container. The
host_data_pathvolume is reused as is: history, learned baseline, exceptions, rules and read positions are kept.