Splunk Enterprise Security

How to get word on search and save on new column tables ?

nisnes12
New Member

Hello guys,

I have a search,

sourcetype=example "testword" OR "abcd" |  table _time _raw 

If I run this query, I get some result because triggered on the testword or abcd (string). My question, how do I find the word that causes the result to appear and that word I display in the table column?

Example:

table
_raw : abcd is the only alphabet
word : abcd
_time : 18:00

_raw : this only testword
word : testword
_time : 18:00

Please help me, create a value of column word from a word on a search, thanks.

0 Karma
1 Solution

renjith_nair
Legend

@nisnes12 ,

Not sure about the use case but it's always better to extract the field and do the comparison. Regardless of that, if you want to find the string matching the event, try this

|eval word_matched=if(searchmatch("abcd"),"abcd","testword")
Happy Splunking!

View solution in original post

0 Karma

FrankVl
Ultra Champion

This feels like a very cumbersome approach to achieve something that might be achieved much more easily in other ways. But without any understanding of the actual data and the end goal that you want to achieve, that is a bit difficult to provide any concrete suggestions.

0 Karma

renjith_nair
Legend

@nisnes12 ,

Not sure about the use case but it's always better to extract the field and do the comparison. Regardless of that, if you want to find the string matching the event, try this

|eval word_matched=if(searchmatch("abcd"),"abcd","testword")
Happy Splunking!
0 Karma

nisnes12
New Member

thanks for your answers, but how to i have many string in the query ? example i have 100 string for condition

0 Karma

niketn
Legend

@nisnes12 in your SPL while filtering data for index do you filter 100 words? Or one or two of 100 values? How do you apply filter? Can you share your current SPL and elaborate your issue?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

nisnes12
New Member

sourcetype=example "testword" OR "abcd" OR "test" OR "ball" OR "happy" (and many more) | table _time _raw

i think good to use case command for this issue, what about you ?

0 Karma

renjith_nair
Legend

@nisnes12, you can use case as well if there are multiple values. However if you have a specific pattern or field where these strings appear, then it would be more efficient and easy. What's your use case and final result you want to achieve?

Happy Splunking!
0 Karma

nisnes12
New Member

yes use case function, how about my word is regex words ? example sourcetype=example "testword" OR "abcd" | eval word=case(match(_raw,"(delmitier)*abc"),"abcd") | table _time _raw
, if i use case , i get error 'Error in 'eval' command: Regex: quantifier does not follow a repeatable item'

0 Karma
Get Updates on the Splunk Community!

.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 ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...