Guide
Coraza and ModSecurity WAF logs
If you run a web application firewall (WAF) built on Coraza or ModSecurity v3 with the OWASP Core Rule Set (CRS), Logthread can read its audit log. Each request the WAF's rules flag becomes one searchable event, with:
- which rules matched;
- the attack type;
- whether the request was blocked or only flagged;
- the client address, method and path.
The same events feed the threat report, four detections and a WAF dashboard.
Logthread never stores the values a rule matched, the rule text, request headers or bodies, or the query string. They can hold passwords, tokens and personal data.
Set it up#
Go to Integrations, choose Coraza and ModSecurity WAF, and answer one question: where the audit log goes.
- A file on the server. The Logthread Agent's
waf-auditprofile reads it. The default path is/var/log/modsec_audit.log, and you can give another one. The records arrive as servicewaf. - Container output (Docker). The WAF writes its records to standard output, and the agent's
dockerprofile reads them with the other container logs, as servicedocker.
Then follow the three steps on the page:
- Switch on the WAF parser first. Choose Use parser and activate it before anything is sent, so no record is ever stored with its values. You see it on the parser's own sample records first. A WAF record the parser cannot read (an unknown layout, larger than 1 MiB, or no rule id) is stored only as "WAF audit record not parsed", with
waf.parse_error: trueand none of its values. - Turn on the JSON audit log. Add these directives to the WAF, then reload it:
- for Coraza, in the directives block of your Caddy, Envoy or Traefik configuration;
- for ModSecurity, in
modsecurity.conf.
``text SecAuditEngine RelevantOnly SecAuditLogFormat JSON SecAuditLogType Serial SecAuditLogParts AHKZ SecAuditLog /var/log/modsec_audit.log # After the OWASP CRS includes: SecRuleUpdateActionById 900000-999999 "logdata:%{MATCHED_VAR_NAME}" ``
AHKZleaves request headers and bodies out of each record.- The last line makes every CRS rule log the field's name instead of the value it matched. With Coraza, a password that trips a rule is then never written to the log file. ModSecurity still writes the matched value in each record's
matchdetail on your server. Logthread's parser never stores it in either case. - For container output, use
SecAuditLog /dev/stdout. - Install the Logthread Agent with the command shown, on the WAF server or the Docker host. For a file, the agent's user must be able to read it: add the agent to the group that owns the file, or make the file group-readable. This needs agent 0.3.4 or later.
For container output, the agent sends every container's output as service docker, so "data arrived" on the setup page means any container output. Check the parser's match count to confirm that WAF records arrive.
The page then offers:
- the WAF dashboard;
- two alerts, each shown with how many records it would have matched in the last 24 hours;
- the WAF detections.
Nothing is created until you choose it.
What each record contains#
| Field | Meaning |
|---|---|
waf.action | block (the WAF refused the request) or detect (flagged only, for example in detection-only mode) |
waf.rule.id, waf.rule.msg | the main rule that matched: the first application attack rule, otherwise the first rule that is not a score. A custom rule (an id outside the CRS range) shows Custom rule, because its message can include the value it matched |
waf.rule.ids, waf.rule.count | the rules that matched, in order (up to 50) |
waf.attack, waf.attacks | the main rule's attack type, and every type in the request: sqli, xss, rce, lfi, rfi, php, java, reputation-scanner, protocol, … |
waf.anomaly.inbound | the CRS inbound anomaly score |
waf.engine | coraza or modsecurity |
waf.server | the server or host name the WAF reports |
waf.oversize | true when the request had more fields than the Logthread WAF inspects |
source.address, http.request.method, url.path | the client, the method and the path (without the query string, path parameters such as ;jsessionid=, or any user name and password in the address) |
http.response.status_code | the status, when the WAF records it (ModSecurity) |
Each record also carries the security fields every Logthread security source writes:
event.dataset: wafandevent.category: intrusion_detection;rule.id,rule.nameandrule.level(12 for a block, 8 for a detection);threat.technique.id:T1190for attacks on the application,T1595.002for scanners only.
Severity is error for a block and warn for a detection. A Coraza record keeps its own time. A ModSecurity record is timed when the agent reads it, because ModSecurity writes local time without a time zone. The body is a one-line summary, for example:
WAF blocked GET /products: SQL Injection Attack Detected via libinjection (942100, sqli)
Search, chart and alert#
- Blocked requests:
event.dataset:waf waf.action:block - Top rules:
event.dataset:waf | stats count() by waf.rule.msg - Who is attacking:
event.dataset:waf waf.action:block | stats count() by source.address - One attack type:
event.dataset:waf waf.attack:sqli
Detections#
Find these under Security → SIEM, or search for "WAF":
| Detection | Fires when |
|---|---|
| One address trips many WAF rules | one client address matches 5 or more different rules within 10 minutes |
| Web vulnerability scanner | 3 or more requests from one address carry a known scanner's user agent within 15 minutes |
| Injection attack blocked by the WAF | the WAF blocks a request carrying a SQL, command, file path, PHP, Java or Node.js injection (any of its attack types, not only the main one) |
| Surge in WAF blocks | more than 100 blocked requests on one server within 10 minutes |
The surge detection uses a fixed limit, not a learned baseline, so set it above your normal level when you turn it on.
Threat report#
Blocked requests count in the threat report's Perimeter section, with the top blocked addresses and paths. A WAF audit log lists only the requests its rules flagged, not every request it inspected, so the report shows Not recorded for this source's processed requests. When WAF records are present, NGINX and other access logs count only their 429 responses as blocked, because the WAF's own record already counts each request it refused with a 403. This applies to the whole workspace: if only some servers sit behind the WAF, the 403s of the others are not counted either.