Splunk Search

Help writting and fixing a rex query

phamxuantung
Communicator

Hello,

I have a raw data that go like this

 

...
in[ 60: ]<3034>
in[ 62: ]<10>
in[ 62: ]<EC_CARDVER>
...

 

 

I want to extract the EC_CARDVER to a field name msg

My rex is

 

| rex field=_raw "(in)\[ 62: \]\<(?P<msg>)\>"

 

But it doesn't seem to catch on. How do I write to extract only the EC_CARDVER but not the 10 above it?

Labels (2)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

Assuming the difference is the first character must not be numerical, try

| rex "in\[ *\d+: *]<(?<msg>\D[^>]+)"

(You don't need to specify field when using _raw.)

View solution in original post

yuanliu
SplunkTrust
SplunkTrust

Assuming the difference is the first character must not be numerical, try

| rex "in\[ *\d+: *]<(?<msg>\D[^>]+)"

(You don't need to specify field when using _raw.)

phamxuantung
Communicator

Your query extract a different fields than what I want, because there're many rows that have 'in [ ]' before, so I tweak it a bit

| rex "in\[ *62+: *]<(?<msg>\D[^>]+)"

Then it work just the way I want it to. Thank you

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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...