SPLK-1002 Macro Expansion Practice Question
A search includes the macro `mysearch(field1, field2)`. The macro definition is `stats count by $1$, $2$`. If the search is `index=main | `mysearch(user, action)`, what is the expanded search?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
`index=main | stats count by user, action`
The macro invocation `| `mysearch(user, action)` expands by replacing `$1$` with `user` and `$2$` with `action` in the definition `stats count by $1$, $2$`, resulting in `| stats count by user, action`. Option A incorrectly leaves the placeholders unreplaced. Option B has an extra pipe symbol, which would cause a syntax error. Option C does not expand the macro; it just references the macro name literally.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
`index=main | stats count by $1$, $2$`
Why it's wrong here
Incorrect. The macro definition replaces $1$ and $2$ with the arguments, but this option keeps the placeholders as-is.
- ✗
`index=main | | stats count by user, action`
Why it's wrong here
Incorrect. This option includes an extra pipe symbol, resulting in two consecutive pipes (`| |`) which is invalid syntax.
- ✗
`index=main | mysearch(user, action)`
Why it's wrong here
Incorrect. This option does not expand the macro; it simply references the macro invocation text literally, not its expansion.
- ✓
`index=main | stats count by user, action`
Why this is correct
Correct. The macro expansion correctly substitutes `user` for $1$ and `action` for $2$, yielding `stats count by user, action`.
Go deeper
Related to this question
About these practice questions
This SPLK-1002 question is part of Courseiva's 475-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SPLK-1002 practice question is part of Courseiva's free Splunk certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SPLK-1002 exam.