Splunk Search

Save SPL commands into one SPL new command

shayhibah
Path Finder

Hi,

Is it possible to save SPL command into one new command and use it when running a query?

For example:
| dedup 1 id | stats count by hostname ----> my_command

When running a query, I want to use it as:
| my_command

How can I do that?

Thanks

Tags (1)
0 Karma

thomasroulet
Path Finder
0 Karma

broberg
Communicator

If you saved this as MySavedSearch

| dedup 1 id | stats count by hostname

Then you can do this:

| savedsearch MySavedSearch

Also, if you schedule MySavedSearch, you could also use loadjob to load the results of the previous run (instead of re-running it ad-hoc).

0 Karma
Get Updates on the Splunk Community!

Celebrating Fast Lane: 2025 Authorized Learning Partner of the Year

At .conf25, Splunk proudly recognized Fast Lane as the 2025 Authorized Learning Partner of the Year. This ...

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...