Splunk Search

How can I optimize my search?

Deepali529
Explorer

This search is taking too much time to execute, around 20 mins. Is it because of the lookup?

index="access_log_index" sourcetype="access_log" | rename agent as http_user_agent | lookup user_agents http_user_agent | stats count by  ua_os_family | rename ua_os_family as os_type

How can I optimize my search? Any suggestions will be appreciated.
Thanks

0 Karma
1 Solution

skoelpin
SplunkTrust
SplunkTrust

You should look at the job inspector and see where most of the time is being spent

https://docs.splunk.com/Documentation/Splunk/6.5.0/Search/ViewsearchjobpropertieswiththeJobInspector

How big is your lookup table?

View solution in original post

skoelpin
SplunkTrust
SplunkTrust

You should look at the job inspector and see where most of the time is being spent

https://docs.splunk.com/Documentation/Splunk/6.5.0/Search/ViewsearchjobpropertieswiththeJobInspector

How big is your lookup table?

Deepali529
Explorer

Thanks skoelpin 🙂
It reduces the execution time of query from 816 seconds to 28 seconds

Deepali529
Explorer

It's quite large lookup. I want to find the OS types so installed TA_user_agents add-on. Lookup is present in it

0 Karma

skoelpin
SplunkTrust
SplunkTrust

"quite large" can be relative.. If your lookup is as massive as you claim then you could always use a case statement to match on rather than a lookup table.. It should be faster but you can test this by creating a simple match case and run it over a small time frame then look at the job inspector to see how long it took. Then run the same sample over the lookup and see how long that took

... | eval os = case(match(useragent,"Windows .. 5\.1"),"Windows XP",match(useragent,"droid"),"Android",match(useragent,"Windows NT 6.1"),"Windows 7") | eval browser = case(match(useragent,"MSIE 10.0"),"Internet Explorer 10.0",match(useragent,"Chrome"),"Chrome",match(useragent,"Safari/"),"Safari") | eval arch = case(match(useragent,"droid"),"android",match(useragent,"iPad"),"ipad",match(useragent,"iPod"),"ipod")
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...