Creating and Using Macros Flashcards

1
Q

Define Macros

A

Search strings or portions of search strings that can be used in multiple places within Splunk.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When are Macros useful?

A

Macros are useful when you frequently run searches that require similar or complicated search syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the goal macros?

A

The goal of macros should always be to make them as reusable as possible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What fields are required for building macros?

A

Name
Definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What characters can macro argument names contain?

A
  • Alphanumeric
  • “_”
  • ”-“
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the syntax for including arguments in macro definitions?

A

Enclose the argument name in dollar signs.

Ex. “$moolah$”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the definition field in a macro?

A

The definition field is the search string that will expand when referenced.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you use a macro in a search string?

A

To use a macro, pipe into a statement using the name of the macro in backtick characters.

Ex.
|convertUSD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What do backtick characters tell Splunk?

A

Backtick characters tell Splunk this is a macro and replace it with the search in the macro definition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How are macros set apart from other knowledge objects?

A

Macros:
- Store entire search strings, including pipes and eval statements.
- Are time range independent, allowing time range to be selected at search time.
- Pass arguments to the search.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you expand a macro without running it?

A

Via the search expansion window (Command Shift E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When can a pipe follow a macro?

A

A pipe can always follow a macro.

Using a basic macro, you can pipe to more commands or precede with a search string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is required for a macro to accept a given number of arguments?

A

Include the number of the arguments in parentheses after the macro name.

Ex.
monthly_sales(3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you define an argument in a macro search definition?

A

Enclose the argument in dollar signs within the search definition.

Ex. (three arguments)
currency=$currency$
symbol=$symbol$
rate=$rate$

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When is a time range selected for a macro?

A

At search time.

Macros have flexible time ranges.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly