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!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...