Skip to content

Commit 685d79a

Browse files
authored
[Apache Tomcat] Fix pipelines to correctly split the X-Forwarded-For comma delineated IPs (#15873)
* fix * Update changelog.yml
1 parent 1ca737d commit 685d79a

File tree

5 files changed

+94
-4
lines changed

5 files changed

+94
-4
lines changed

packages/apache_tomcat/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.12.1"
3+
changes:
4+
- description: Fix IP seperator regex for access logs
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/15873
27
- version: "1.12.0"
38
changes:
49
- description: Improve documentation

packages/apache_tomcat/data_stream/access/_dev/test/pipeline/test-access.log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
81.2.69.144 - admin [02/Mar/2023:18:58:17 +0530] "POST /host-manager/images/asf-logo.svg HTTP/1.1" 200 20486 ms:54321 X 400 "http://localhost:8080/host-manager/html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" X-Forwarded-For="127.0.0.1"
1414
81.2.69.144 - admin [02/Mar/2023:18:58:17 +0530] "POST /host-manager/images/asf-logo.svg HTTP/1.1" 200 20486 ms:3214 81.2.69.145 40 "http://localhost:8080/host-manager/html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" X-Forwarded-For="127.0.0.1, 127.0.0.3"
1515
81.2.69.144 - admin [02/Mar/2023:18:58:17 +0530] "POST /host-manager/images/asf-logo.svg HTTP/1.1" 200 20486 ms:98765 50 "http://localhost:8080/host-manager/html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" X-Forwarded-For=""
16-
10.10.10.10 - - [28/May/2024:17:20:05 +0200] "GET / " 200 17 ms:1234
16+
10.10.10.10 - - [28/May/2024:17:20:05 +0200] "GET / " 200 17 ms:1234
17+
81.2.69.144 - admin [02/Mar/2023:18:58:17 +0530] "POST /host-manager/images/asf-logo.svg HTTP/1.1" 200 20486 ms:3214 81.2.69.145 40 "http://localhost:8080/host-manager/html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" X-Forwarded-For="127.0.0.1,127.0.0.3, 127.0.0.4"

packages/apache_tomcat/data_stream/access/_dev/test/pipeline/test-access.log-expected.json

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,90 @@
10901090
"tags": [
10911091
"preserve_original_event"
10921092
]
1093+
},
1094+
{
1095+
"@timestamp": "2023-03-02T13:28:17.000Z",
1096+
"apache_tomcat": {
1097+
"access": {
1098+
"http": {
1099+
"ident": "-",
1100+
"useragent": "admin"
1101+
},
1102+
"ip": {
1103+
"local": "81.2.69.145"
1104+
},
1105+
"request_process_time": 3214.0,
1106+
"response_time": 40.0
1107+
}
1108+
},
1109+
"client": {
1110+
"ip": [
1111+
"127.0.0.1",
1112+
"127.0.0.3",
1113+
"127.0.0.4"
1114+
]
1115+
},
1116+
"destination": {
1117+
"bytes": 20486
1118+
},
1119+
"ecs": {
1120+
"version": "8.11.0"
1121+
},
1122+
"event": {
1123+
"category": [
1124+
"web"
1125+
],
1126+
"kind": "event",
1127+
"module": "apache_tomcat",
1128+
"original": "81.2.69.144 - admin [02/Mar/2023:18:58:17 +0530] \"POST /host-manager/images/asf-logo.svg HTTP/1.1\" 200 20486 ms:3214 81.2.69.145 40 \"http://localhost:8080/host-manager/html\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36\" X-Forwarded-For=\"127.0.0.1,127.0.0.3, 127.0.0.4\"",
1129+
"outcome": "success",
1130+
"type": [
1131+
"access"
1132+
]
1133+
},
1134+
"http": {
1135+
"request": {
1136+
"method": "POST",
1137+
"referrer": "http://localhost:8080/host-manager/html"
1138+
},
1139+
"response": {
1140+
"status_code": 200
1141+
},
1142+
"version": "1.1"
1143+
},
1144+
"related": {
1145+
"ip": [
1146+
"81.2.69.144",
1147+
"81.2.69.145",
1148+
"127.0.0.1",
1149+
"127.0.0.3",
1150+
"127.0.0.4"
1151+
]
1152+
},
1153+
"source": {
1154+
"ip": "81.2.69.144"
1155+
},
1156+
"tags": [
1157+
"preserve_original_event"
1158+
],
1159+
"url": {
1160+
"extension": "svg",
1161+
"original": "/host-manager/images/asf-logo.svg",
1162+
"path": "/host-manager/images/asf-logo.svg"
1163+
},
1164+
"user_agent": {
1165+
"device": {
1166+
"name": "Other"
1167+
},
1168+
"name": "Chrome",
1169+
"original": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
1170+
"os": {
1171+
"full": "Windows 10",
1172+
"name": "Windows",
1173+
"version": "10"
1174+
},
1175+
"version": "109.0.0.0"
1176+
}
10931177
}
10941178
]
1095-
}
1179+
}

packages/apache_tomcat/data_stream/access/elasticsearch/ingest_pipeline/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ processors:
163163
if: ctx._tmp?.header_forwarder != null && ctx._tmp.header_forwarder != '' && ctx._tmp.header_forwarder != '-'
164164
tag: 'split_x_forwarded_for'
165165
target_field: client.ip
166-
separator: ', '
166+
separator: ',\s?'
167167
- foreach:
168168
field: client.ip
169169
if: ctx.client?.ip instanceof List

packages/apache_tomcat/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: "3.0.2"
22
name: apache_tomcat
33
title: Apache Tomcat
4-
version: "1.12.0"
4+
version: "1.12.1"
55
description: Collect and parse logs and metrics from Apache Tomcat servers with Elastic Agent.
66
categories:
77
- web

0 commit comments

Comments
 (0)