Splunk Search

FInd multiple keywords in file and show them on a chart

raffaeledifazio
Engager

I have a CSV file in which I have a column containing timestamps and a column containing text. I want to be albe to look for occurrences of certain keywords (let's say 10 keywords) and to show the number of occurrences of each keyword on a chart. It would also be good to find a display them over time. What I do not understand is how to search for multiple keywords on this strings while counting the occurrences... can you help me?

Example file (where timestamp represent the day):

TIMESTAMP;TEXT_STRING
20;The quick brown fox jumps over the lazy dog

Tags (3)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

Assuming that you have a csv file with headers (e.g. timestamp and string), you could use the inputlookup feature to load the file as search results.

| inputlookup file.csv 
| rex field=string "(?<word>\S+)" max_match=0 
| mvexpand word 
| table timestamp word 
| search word=xxx OR word=yyy OR word=zzz 
| top 10 word

Add more words in the 'search' statement above. The last statement can be changed for

| chart count over timestamp by word

There are probably more than one way to do this, and probably more efficient than this.

/K

View solution in original post

kristian_kolb
Ultra Champion

Assuming that you have a csv file with headers (e.g. timestamp and string), you could use the inputlookup feature to load the file as search results.

| inputlookup file.csv 
| rex field=string "(?<word>\S+)" max_match=0 
| mvexpand word 
| table timestamp word 
| search word=xxx OR word=yyy OR word=zzz 
| top 10 word

Add more words in the 'search' statement above. The last statement can be changed for

| chart count over timestamp by word

There are probably more than one way to do this, and probably more efficient than this.

/K

raffaeledifazio
Engager

Thanks, this helps a lot.

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