Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #25482 to 7.x: [Filebeat] Additional parsing for haproxy.http.request.raw_request_line #25496

Merged
merged 2 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- New module `cyberarkpas` for CyberArk Privileged Access Security audit logs. {pull}24803[24803]
- Add `uri_parts` processor to Apache, Nginx, IIS, Traefik, S3Access, Cisco, F5, Fortinet, Google Workspace, Imperva, Microsoft, Netscout, O365, Sophos, Squid, Suricata, Zeek, Zia, Zoom, and ZScaler modules ingest pipelines. {issue}19088[19088] {pull}24699[24699]
- New module `zookeeper` for Zookeeper service and audit logs {issue}25061[25061] {pull}25128[25128]
- Add parsing for `haproxy.http.request.raw_request_line` field {issue}25480[25480] {pull}25482[25482]

*Heartbeat*

Expand Down
33 changes: 33 additions & 0 deletions filebeat/module/haproxy/log/ingest/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ processors:
field: haproxy.request_date
- remove:
field: message
- grok:
field: haproxy.http.request.raw_request_line
patterns:
- '%{WORD:http.request.method}%{SPACE}%{URIPATHPARAM:url.original}%{SPACE}HTTP/%{NUMBER:http.version}'
ignore_missing: true
- uri_parts:
field: url.original
ignore_failure: true
if: ctx?.url?.original != null
- grok:
field: source.address
ignore_failure: true
Expand Down Expand Up @@ -135,6 +144,30 @@ processors:
field: event.outcome
value: failure
if: "ctx?.http?.response?.status_code != null && ctx.http.response.status_code >= 400"
- script:
lang: painless
description: This script processor iterates over the whole document to remove fields with null values.
source: |
void handleMap(Map map) {
for (def x : map.values()) {
if (x instanceof Map) {
handleMap(x);
} else if (x instanceof List) {
handleList(x);
}
}
map.values().removeIf(v -> v == null);
}
void handleList(List list) {
for (def x : list) {
if (x instanceof Map) {
handleMap(x);
} else if (x instanceof List) {
handleList(x);
}
}
}
handleMap(ctx);
on_failure:
- set:
field: error.message
Expand Down
7 changes: 6 additions & 1 deletion filebeat/module/haproxy/log/test/haproxy.log-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
"haproxy.server_queue": 0,
"haproxy.termination_state": "----",
"haproxy.total_waiting_time_ms": 0,
"http.request.method": "GET",
"http.response.bytes": 168,
"http.response.status_code": 304,
"http.version": "1.1",
"input.type": "log",
"log.offset": 0,
"process.name": "haproxy",
Expand All @@ -53,6 +55,9 @@
"source.geo.region_iso_code": "RU-MOW",
"source.geo.region_name": "Moscow",
"source.ip": "1.2.3.4",
"source.port": 38862
"source.port": 38862,
"url.extension": "js",
"url.original": "/component---src-pages-index-js-4b15624544f97cf0bb8f.js",
"url.path": "/component---src-pages-index-js-4b15624544f97cf0bb8f.js"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
"haproxy.server_queue": 0,
"haproxy.termination_state": "SC--",
"haproxy.total_waiting_time_ms": -1,
"http.request.method": "GET",
"http.response.bytes": 213,
"http.response.status_code": 503,
"http.version": "1.1",
"input.type": "log",
"log.offset": 0,
"process.name": "haproxy",
Expand All @@ -41,7 +43,9 @@
"service.type": "haproxy",
"source.address": "127.0.0.1",
"source.ip": "127.0.0.1",
"source.port": 35982
"source.port": 35982,
"url.original": "/",
"url.path": "/"
},
{
"event.category": [
Expand Down Expand Up @@ -73,8 +77,10 @@
"haproxy.server_queue": 0,
"haproxy.termination_state": "SC--",
"haproxy.total_waiting_time_ms": -1,
"http.request.method": "GET",
"http.response.bytes": 213,
"http.response.status_code": 503,
"http.version": "1.1",
"input.type": "log",
"log.offset": 186,
"process.name": "haproxy",
Expand All @@ -85,7 +91,9 @@
"service.type": "haproxy",
"source.address": "127.0.0.1",
"source.ip": "127.0.0.1",
"source.port": 43738
"source.port": 43738,
"url.original": "/foo",
"url.path": "/foo"
},
{
"event.category": [
Expand Down Expand Up @@ -121,8 +129,10 @@
"haproxy.server_queue": 0,
"haproxy.termination_state": "SC--",
"haproxy.total_waiting_time_ms": -1,
"http.request.method": "GET",
"http.response.bytes": 213,
"http.response.status_code": 503,
"http.version": "1.1",
"input.type": "log",
"log.offset": 394,
"process.name": "haproxy",
Expand All @@ -133,6 +143,8 @@
"service.type": "haproxy",
"source.address": "127.0.0.1",
"source.ip": "127.0.0.1",
"source.port": 44542
"source.port": 44542,
"url.original": "/foo",
"url.path": "/foo"
}
]