nerdexam
Splunk

SPLK-1002 · Question #80

What is the correct way to name a macro with two arguments?

The correct answer is D. us_sales(2). In Splunk, a macro that accepts arguments is named using the format macroname(N), where N is the integer count of arguments the macro expects.

Creating and Using Macros

Question

What is the correct way to name a macro with two arguments?

Options

  • Aus_sales2
  • Bus_sales(1,2)
  • Cus_sale,2
  • Dus_sales(2)

How the community answered

(63 responses)
  • A
    3% (2)
  • B
    2% (1)
  • C
    6% (4)
  • D
    89% (56)

Why each option

In Splunk, a macro that accepts arguments is named using the format macroname(N), where N is the integer count of arguments the macro expects.

Aus_sales2

us_sales2 is treated as a zero-argument macro named literally 'us_sales2'; appending the number to the name without parentheses does not define argument count in Splunk's macro naming convention.

Bus_sales(1,2)

us_sales(1,2) is not valid macro naming syntax; the parentheses must contain only the integer count of arguments, not a list of argument values or names.

Cus_sale,2

us_sale,2 is syntactically invalid for a macro name; commas are not used in macro naming and this form would not be recognized by the Splunk macro system.

Dus_sales(2)Correct

us_sales(2) is the correct naming convention for a Splunk macro with two arguments; the argument count in parentheses is part of the macro's unique identifier, so us_sales(2) is a distinct macro from us_sales or us_sales(1).

Concept tested: Splunk macro naming convention with arguments

Source: https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Definesearchmacros

Topics

#Splunk Macros#Macro Arguments#Naming Conventions

Community Discussion

No community discussion yet for this question.

Full SPLK-1002 Practice