Splunk Search

Regular Expression for Field Extract custom log

thuhnv
New Member

Hello,
Can anyone help me to extract some field as I need like POS CODE, POS NAME, POS ID with these value:
[POS CODE, POS NAME, POS ID]
[112044, GIA THỊNH , 9476]
[112044, GIA THỊNH , 9476]
.....

Can someone help me with regex to do this?

Any help is appreciated for me. Thanks.

2015-10-09 14:27:20,927 DEBUG com.nocldfr.com.bean.listhandler.ListHandlerBean - performSearch in the bean outside [4676, 234, [POS CODE, POS NAME, POS ID], [112044, GIA THỊNH , 9476], [605032, LÝ PHÚ _NO, 9437], [1000165, MINH NGỌC ANH, 6271], [606073, THIÊN ANH , 9436], [135042, 282 QUANG TRUNG, 9743], [120095, 289 HÀ THÀNH, 7705], [604135, A LÀNH_NO, 7987], [601144, A LÔ XINH, 8676], [604219, A MẠNH HIỀN_NO, 9131], [622029, A. ĐẠT MOBILE, 8449], [624022, AGG - 188 Tôn Đức Thắng , 7606], [624002, AGG-243 Lê Lợi, 5749], [624008, AGG-244 Trần Hưng Đạo, 5910], [624001, AGG-311 Trần Hưng Đạo, 5669], [606077, ALO, 9583], [606079, ALO XINH_NO, 9794], [614023, ALÔ MOBILE_NO, 8851], [133023, AN BIÊN 2, 1130], [627055, AN BÌNH_NO, 9246], [125013, AN CHÂU CHƯƠNG 1, 676]]

Tags (2)
0 Karma

thuhnv
New Member

Thanks somesoni2,

But this does not show any fields extract on this search:
index=cas | rex field=_raw max_match=0 "[(?\d+),\s*(?[^,]+),(?\d+)]"

I tried to use Field Extraction but can not extract more values with the same Field name, So I need to use Regex.
I would like to extract 3 field according values i can see like this:
POS_CODE which is the first value on event: [112044, GIA THỊNH , 9476] [605032, LÝ PHÚ _NO, 9437] [1000165, MINH NGỌC ANH, 6271] ... and so on on the event

POS_NAME which is the second value on event: [112044, GIA THỊNH , 9476] [605032, LÝ PHÚ _NO, 9437] [1000165, MINH NGỌC ANH, 6271] ... and so on on the event

POS_ID which is the third value on the event: [112044, GIA THỊNH , 9476] [605032, LÝ PHÚ _NO, 9437] [1000165, MINH NGỌC ANH, 6271] ... and so on on the event

Thanks for your help

0 Karma

somesoni2
Revered Legend

Try something like this

your base search | rex field=_raw max_match=0 "\[(?<POS_CODE>\d+),\s*(?<POS_NAME>[^,]+),(?<POS_ID>\d+)\]" 
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Data Management Digest – September 2026

    Welcome to the September 2026 edition of Data Management Digest! September brought a fresh wave of ...

Federated Search for CloudWatch Unified Data Store Is Generally Available

As organizations modernize their cloud environments, AWS workloads generate more security, operational, and ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...