nerdexam
Splunk

SPLK-1002 · Question #146

The macro weekly sales (2) contains the search string: index=games | eval ProductSales = $Price$ * $AmountSold$ Which of the following will return results?

The correct answer is C. 'weekly_sales (3.99, 10)'. To use a search macro in a search string, you need to place a back tick character (`) before and after the macro name. You also need to use the same number of arguments as defined in the macro. The macro weekly sales (2) has two arguments: Price and AmountSold. Therefore, you…

Creating and Using Macros

Question

The macro weekly sales (2) contains the search string:

index=games | eval ProductSales = $Price$ * $AmountSold$ Which of the following will return results?

Options

  • A`weekly sales (3)'
  • B`weekly_sales($3.995, $108)'
  • C'weekly_sales (3.99, 10)'
  • D`weekly sales (3.99, 10)'

How the community answered

(16 responses)
  • A
    6% (1)
  • B
    13% (2)
  • C
    81% (13)

Explanation

To use a search macro in a search string, you need to place a back tick character (`) before and after the macro name. You also need to use the same number of arguments as defined in the macro. The macro weekly sales (2) has two arguments: Price and AmountSold. Therefore, you need to provide two values for these arguments when you call the macro. The option A is incorrect because it uses parentheses instead of back ticks around the macro name. The option B is incorrect because it uses underscores instead of spaces in the macro name. The option D is incorrect because it uses spaces instead of commas to separate the argument values. Reference: 1 Use search macros in searches - Splunk Documentation 2 Define search macros in Settings - Splunk Documentation

Topics

#Splunk Macros#Macro Arguments#Macro Syntax#Eval Command

Community Discussion

No community discussion yet for this question.

Full SPLK-1002 Practice