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")
---
What goes around comes around. If it helps, hit it with Karma 🙂

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")
---
What goes around comes around. If it helps, hit it with Karma 🙂
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?

---
What goes around comes around. If it helps, hit it with Karma 🙂
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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...