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!

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