Skip to main content
Registration for .conf24 is open! Join us June 11-14 in Las Vegas.
Splunk Lantern

Using advanced macros


As an analyst working with Splunk Enterprise or Splunk Cloud Platform, you frequently run searches requiring similar or complicated search syntax. You're looking for ways to reuse portions of the Splunk Search Processing Language (SPL), so they can be inserted into other searches, or executed on their own.


Macros allow you to reuse portions of SPL in this way. You can create macros on your own, and pre-written macros also are used heavily in different Splunk solutions, like Splunk Enterprise Security, Splunk ITSI, and the Splunk Common Information Model.

This video shows you:

  • How to create macros
  • How to edit an existing macro
  • How to add arguments
  • How to create a nested macro
  • How to troubleshoot macros
  • An example macro in action: How to create a macro that queries the total sales revenue of a particular region

Next steps

This article has been brought to you by Splunk Education. We’ve learned that the strongest superheroes up-skill with Splunk Education. That’s why we are making Splunk training easier and more accessible than ever with more than 20 self-paced, free eLearning courses. You can start with foundational courses like Intro to Splunk or dive into more advanced courses like Search Under the HoodResult Modification, and many more. Enroll today so you have the skills to detect the good, the bad, and the unproductive.

In addition, these Splunk resources might help you understand and implement this use case: