Splunk Search

get substring from long raw string

tsek13
New Member

Hi guys, i am newbie in Splunk and i have the following indexed line:

Mar 21 20:12:14 HOST program name: 2013-03-21 20:12:14,424 | INFO  | Event 'x.y|z.k|asdfvgh|sdfklsd|sdfsdtrwe|asafhwej|qoqwpeirw|' is not allowed. | sdfsdfsdfsd | sdfsdfwerwe thread #8 - Jfsdfsdfssd]

How can I do this:
- get only x.y|z.k|asdfvgh|sdfklsd|sdfsdtrwe|asafhwej|qoqwpeirw
- put the string x.y|.z.k... in new field (a =x.y|...)
- Remove duplicate values
- count all distinct strings
- generate chart or timechart or an hitmap with number of distinct strings

Thanhs for all your suport

0 Karma
1 Solution

lguinn2
Legend

Try this:

yoursearchhere
| rex "Event \'(?<messageString>.*?)\' is not allowed."
| stats count by messageString

or

yoursearchhere
| rex "Event \'(?<messageString>.*?)\' is not allowed."
| timechart distinct_count(messageString)

Replace "yoursearchhere" with whatever makes sense; that might mean something like sourcetype=xyz
Did you need to restrict the search only to events that actually contain a messageString?

View solution in original post

0 Karma

tsek13
New Member

Many thanks Iguinn!
Yes, I need to restrict only to events that contain a messageString but for now your hint works fine!

0 Karma

lguinn2
Legend

Try this:

yoursearchhere
| rex "Event \'(?<messageString>.*?)\' is not allowed."
| stats count by messageString

or

yoursearchhere
| rex "Event \'(?<messageString>.*?)\' is not allowed."
| timechart distinct_count(messageString)

Replace "yoursearchhere" with whatever makes sense; that might mean something like sourcetype=xyz
Did you need to restrict the search only to events that actually contain a messageString?

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...