Dear community,
I am working on my first pipeline rule. I stumbled accross something, I don’t understand. I want to parse a message and use regex to write values in additional fields. I am pretty sure, that my regex is valid, but no messages are processed. When I copy the received message, there are other fields available, as in the GUI.
What do I have to do, to store source-ip, destination-ip and the ports in dedicated fields?
example message (syslog input from Unifi)
<4>Dec 26 10:33:49 USG-3P kernel: [LAN_LOCAL-default-A]IN=eth1 OUT= MAC=24:5a:4c:7b:37:aa:18:e8:29:b6:50:73:08:00 SRC=192.168.1.2 DST=192.168.1.1 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=430 DF PROTO=TCP SPT=8080 DPT=52663 WINDOW=246 RES=0x00 ACK URGP=0
my pipeline rule
rule "Regex Test"
when
contains(to_string($message.source), "usg", true)
then
let values = regex("^.*((?<=SRC=)\\d+\\.\\d+\\.\\d+\\.\\d+).*((?<=DST=)\\d+\\.\\d+\\.\\d+\\.\\d+).*((?<=PROTO=)\\w+).*((?<=SPT=)\\d+).*((?<=DPT=)\\d+).*$", (to_string($message.message)));
set_field("source IP", values["0"]);
end
screenshot from GUI
content of “copy message”
e.g. there is already a remote_ip and remote_port available, but not shown in the GUI above.
{
"gl2_accounted_message_size": 630,
"level": 4,
"gl2_remote_ip": "192.168.70.1",
"gl2_remote_port": 45792,
"streams": [
"000000000000000000000001",
"63a623024dde366c72447bb8"
],
"gl2_message_id": "01GN6WVF6J7QK5AAAVXAVPPA7Q",
"source": "USG-3P",
"message": "USG-3P kernel: [LAN_LOCAL-default-A]IN=eth1 OUT= MAC=24:5a:4c:7b:37:aa:18:e8:29:b6:50:73:08:00 SRC=192.168.1.2 DST=192.168.1.1 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=8174 DF PROTO=TCP SPT=8080 DPT=52682 WINDOW=314 RES=0x00 ACK FIN URGP=0",
"gl2_source_input": "63a61d1a4dde366c72446f31",
"full_message": "<4>Dec 26 10:40:06 USG-3P kernel: [LAN_LOCAL-default-A]IN=eth1 OUT= MAC=24:5a:4c:7b:37:aa:18:e8:29:b6:50:73:08:00 SRC=192.168.1.2 DST=192.168.1.1 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=8174 DF PROTO=TCP SPT=8080 DPT=52682 WINDOW=314 RES=0x00 ACK FIN URGP=0",
"facility_num": 0,
"gl2_source_node": "e3923345-1eb2-43a2-8339-c60bf94e7539",
"_id": "4820e410-8501-11ed-b8d9-02420a0a0a02",
"facility": "kernel",
"timestamp": "2022-12-26T09:40:06.000Z"
}