Splunk Search

What's the wrong in this search?

jangid
Builder

I want to extract processid from my log and here is query

eventtype=statustrace | regex _raw="^[IEWF]" | rex field=_raw "(?i)^(?:[^ ]* ){2}(?P[^ ]+)" | table _raw ProcessID

this return following result

    I0704 16:04:06.612287 3690 logger_c.cpp:42] ThreadData.c:5253 STATUSTRACE: 14, INPUT
    I0704 16:04:06.611132 3690 logger_c.cpp:42] ThreadData.c:5253 STATUSTRACE: 11, NORMAL

47653 I0704 11:14:28.963080 47653 logger_c.cpp:42] ThreadData.c:5253 STATUSTRACE: 11, NORMAL
47653 I0704 11:14:12.682859 47653 logger_c.cpp:42] ThreadData.c:5253 STATUSTRACE: 12, SLEEPING

Why its not return 3690 in first two row?
is something wrong my regular expression?

Tags (2)
0 Karma
1 Solution

ahall_splunk
Splunk Employee
Splunk Employee

Yes, there is something wrong with your regex. At least, it didn't match your data. I use an online regular expression tester for testing these sorts of things. Online, you can try: http://www.regextester.com/ - offline, I use an Eclipse plug-in.

Try something like:

rex field=_raw "^[IEWF]\d+ [0-9:\.]+ (?<processid>\d+)"

View solution in original post

ahall_splunk
Splunk Employee
Splunk Employee

Yes, there is something wrong with your regex. At least, it didn't match your data. I use an online regular expression tester for testing these sorts of things. Online, you can try: http://www.regextester.com/ - offline, I use an Eclipse plug-in.

Try something like:

rex field=_raw "^[IEWF]\d+ [0-9:\.]+ (?<processid>\d+)"

jangid
Builder

Thanks for your reply

below regex solved my problem
rex field=_raw "\w+\s\d+:\d+:\d+.\d+\s+(?\d+)\s"

0 Karma

ahall_splunk
Splunk Employee
Splunk Employee

Field names are case sensitive, so ensure your extraction matches the field in the table command.

0 Karma

jangid
Builder

same result with your regex 😞

0 Karma

jangid
Builder

I have noticed one thing if process id is 5 or more digit then it'll search other wise it'll not

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...