nerdexam
Splunk

SPLK-1002 · Question #169

Which of the following eval commands will provide a new value for host from src if it exists?

The correct answer is D. | eval host = if (isnotnull (src), src, host). The goal is to replace host with the value of src only when src actually has a value (is not null). Option D - | eval host = if(isnotnull(src), src, host) - correctly reads: 'if src is not null (i.e., it exists and has a value), set host to src; otherwise keep host.' Option A use

Creating and Managing Fields

Question

Which of the following eval commands will provide a new value for host from src if it exists?

Options

  • A| eval host = if (isnu11 (src), src, host)
  • B| eval host = if (NOT src = host, src, host)
  • C| eval host = if (src = host, src, host)
  • D| eval host = if (isnotnull (src), src, host)

How the community answered

(22 responses)
  • A
    5% (1)
  • C
    5% (1)
  • D
    91% (20)

Explanation

The goal is to replace host with the value of src only when src actually has a value (is not null). Option D - | eval host = if(isnotnull(src), src, host) - correctly reads: 'if src is not null (i.e., it exists and has a value), set host to src; otherwise keep host.' Option A uses isnull(src) which has the condition backwards (it would use src when it's null). Options B and C compare src to host using equality, which tests whether the values match, not whether src exists - neither reliably checks for field existence.

Topics

#eval command#field manipulation#conditional logic#isnotnull

Community Discussion

No community discussion yet for this question.

Full SPLK-1002 Practice