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

Change grok pattern to fetch correct IP from X-Forwarded-For list #4351

Merged
merged 3 commits into from
May 29, 2017
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.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ https://github.com/elastic/beats/compare/v5.4.0...v6.0.0-alpha1[View commits]
- Add filebeat.config.path as replacement for config_dir. {pull}4051[4051]
- Add a `recursive_glob.enabled` setting to expand `**` in patterns. {pull}3980[3980]
- Add Icinga module. {pull}3904[3904]
- Add ability to parse nginx logs exposing the X-Forwarded-For header instead of the remote address.

*Heartbeat*

Expand Down
2 changes: 1 addition & 1 deletion filebeat/module/nginx/access/ingest/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"grok": {
"field": "message",
"patterns":[
"%{IPORHOST:nginx.access.remote_ip} - %{DATA:nginx.access.user_name} \\[%{HTTPDATE:nginx.access.time}\\] \"%{WORD:nginx.access.method} %{DATA:nginx.access.url} HTTP/%{NUMBER:nginx.access.http_version}\" %{NUMBER:nginx.access.response_code} %{NUMBER:nginx.access.body_sent.bytes} \"%{DATA:nginx.access.referrer}\" \"%{DATA:nginx.access.agent}\""
"%{IPORHOST:nginx.access.remote_ip}(,\\s%{IPORHOST})* - %{DATA:nginx.access.user_name} \\[%{HTTPDATE:nginx.access.time}\\] \"%{WORD:nginx.access.method} %{DATA:nginx.access.url} HTTP/%{NUMBER:nginx.access.http_version}\" %{NUMBER:nginx.access.response_code} %{NUMBER:nginx.access.body_sent.bytes} \"%{DATA:nginx.access.referrer}\" \"%{DATA:nginx.access.agent}\""
],
"ignore_missing": true
}
Expand Down
1 change: 1 addition & 0 deletions filebeat/module/nginx/access/test/test.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.0.0.2, 10.0.0.1, 127.0.0.1 - - [07/Dec/2016:11:05:07 +0100] "GET /ocelot HTTP/1.1" 200 571 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0"
58 changes: 58 additions & 0 deletions filebeat/module/nginx/access/test/test.log-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"_index": "filebeat-2016.12.27",
"_type": "log",
"_id": "AVlBCaYsqYg9cc5KQfcT",
"_score": null,
"_source": {
"@timestamp": "2016-12-07T10:05:07.000Z",
"offset": 191,
"nginx": {
"access": {
"referrer": "-",
"response_code": "200",
"remote_ip": "10.0.0.2",
"method": "GET",
"user_name": "-",
"http_version": "1.1",
"body_sent": {
"bytes": "571"
},
"url": "/ocelot",
"user_agent": {
"major": "49",
"minor": "0",
"os": "Mac OS X 10.12",
"os_minor": "12",
"os_major": "10",
"name": "Firefox",
"os_name": "Mac OS X",
"device": "Other"
}
}
},
"beat": {
"hostname": "192-168-0-7.rdsnet.ro",
"name": "192-168-0-7.rdsnet.ro",
"version": "6.0.0-alpha1"
},
"read_timestamp": "2016-12-27T15:52:23.304Z",
"source": "module/nginx/access/test/test.log",
"fields": {
"pipeline_id": "nginx-access-with_plugins",
"source_type": "nginx-access"
},
"prospector": {
"type": "log"
}
},
"fields": {
"@timestamp": [
1481105107000
]
},
"sort": [
1481105107000
]
}
]