All Apps and Add-ons

Is there any way to manage similar queries without app that runs on Splunk Enterprise?

t_zhuj
New Member

I have multiple searches, with almost the same search commands and only one of the variables are different for each search. It is too tedious to run the searches tens of times by changing the variable every time. I know that app could manage that, but I am using Splunk Free. Is there any way to simplify this process? Thanks!

0 Karma

Lucas_K
Motivator

Create a list of those variables (potentially from another search or even a lookup file for ease of modification using an APP) and then run the searches via a map command.

This way you can have the same search run over and over with just different variables.

Map command - https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map

Cut & Paste Example :

| eventcount summarize=false index=* 
| map maxsearches=1000 search="| metadata type=sourcetypes index=\"$index$\" splunk_server=\"$server$\" | eval index=\"$index$\" | eval server=\"$server$\" " 
| fields index server sourcetype totalCount | stats sum(totalCount) AS eventCount by index, sourcetype

Note that the internal search is surrounded by quotes of its own! The variables are surrounded by single dollar signs on either side.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...