Courseiva

CCNA Transforming Commands And Formatting Questions

40 questions · Transforming Commands And Formatting · All types, answers revealed

1
MCQeasy

Which command is used to display specific fields in the output?

A.display
B.select
C.fields
D.show
AnswerC

The `fields` command explicitly includes or excludes named fields from results, satisfying the requirement to display only specific fields. Unlike `table`, which also reorders columns, `fields` preserves the existing field order and is the documented SPL command for selecting which fields appear in output.

Why this answer

The fields command is used to display specific fields in the output of a search. By specifying fields field1, field2, you instruct Splunk to include only those fields in the results, effectively displaying just the fields you need. This is the standard SPL command for controlling which fields appear in search output.

Exam trap

SPLK-1004 often tests whether candidates confuse the fields command with SQL-like commands such as select or show, tempting them to choose options that do not exist in Splunk's SPL.

How to eliminate wrong answers

Option A is wrong because 'display' is not a valid Splunk SPL command — it does not exist in the search processing language. Option B is wrong because 'select' is not a Splunk SPL command; it is a SQL keyword and has no equivalent function in Splunk searches. Option D is wrong because 'show' is not a valid SPL command for displaying fields — while some commands like show source or show sourcetype exist in specific contexts, 'show' alone is not used to select fields for output.

2
MCQmedium

A Splunk user needs to format the 'duration' field, which is in seconds, into a string in the format 'HH:MM:SS'. Which eval function should be used?

A.strftime
B.tostring with duration format
C.tostring
D.toint
AnswerB

The 'tostring' function can accept a second argument specifying a format. For durations, using 'tostring(duration, "duration")' converts the numeric seconds into a string in the format 'HH:MM:SS'. This is the correct function to use. It is specifically designed to handle duration formatting, unlike the other options. The 'duration' format is one of the supported formats for 'tostring'.

Why this answer

The 'tostring' function in Splunk can convert a numeric field into a string with a specified format. When the second argument is 'duration', it interprets the numeric value as seconds and returns a string in 'HH:MM:SS' format. This is the intended use for formatting durations.

Other functions like 'strftime' are for timestamps, not durations. Therefore, 'tostring' with the 'duration' format is the correct choice.

Exam trap

The trap here is confusing duration formatting with timestamp formatting; 'strftime' is for epoch times, while 'tostring' with 'duration' is for elapsed seconds.

3
Multi-Selectmedium

Which TWO are true about the 'eval' command?

Select 2 answers
A.It does not create new fields.
B.It can be used to perform logical evaluations.
C.It is a generating command.
D.It is used to filter events.
E.It can be used to perform math operations.
AnswersB, E

The eval command evaluates conditional expressions using operators such as if, case, and comparison functions, returning values based on whether conditions are true or false. This satisfies the logical-evaluation requirement, enabling field values to be derived from boolean tests within the search.

Why this answer

Option B is correct because the 'eval' command in Splunk can perform logical evaluations, such as using if(), case(), or comparison operators to produce boolean or conditional results. Option E is also correct because 'eval' is commonly used to perform math operations, including arithmetic on numeric fields or expressions, and to assign the result to a new or existing field. Option A is incorrect because 'eval' does create new fields when you specify a field name on the left side of the expression, such as 'eval total=price*qty'.

Option C is incorrect because 'eval' is not a generating command; generating commands like 'makeresults' or 'tstats' create events or results, whereas 'eval' is a streaming/eval command that operates on existing results. Option D is incorrect because filtering events is done by search commands such as 'search', 'where', or 'filter', not by 'eval' itself.

Exam trap

SPLK-1004 often tests the distinction between eval and where, as both can perform logical evaluations, but eval creates fields while where filters events.

4
MCQmedium

A security analyst needs to correlate failed login events with subsequent successful logins from the same source IP within a 10-minute window. The raw events contain src_ip and action fields but no session identifier. Which Splunk transforming command should the analyst use to group these events into sessions based on time proximity?

A.transaction
B.stats
C.streamstats
D.join
AnswerA

The transaction command groups events that share a common field value into a single event, using maxspan or maxpause to define the time window. Specifying maxpause=10m allows the analyst to correlate failed and successful logins from the same src_ip within 10 minutes, even without a session ID, producing a combined event with duration and event count.

Why this answer

The transaction command is designed to group related events into a single event based on shared field values and time constraints such as maxspan or maxpause. By setting maxpause=10m and grouping by src_ip, the analyst can correlate failed and successful logins that occur within 10 minutes, creating session-like events without needing a pre-existing session identifier.

Exam trap

The trap here is assuming that stats or streamstats can enforce a time-based grouping similar to transaction, when only transaction provides maxpause and maxspan parameters for sessionization.

5
Multi-Selectmedium

Which TWO of the following are true about 'eventstats'?

Select 2 answers
A.It is faster than stats.
B.It removes non-aggregated fields.
C.It calculates aggregates for each event.
D.It adds aggregate fields to all events.
E.It replaces the existing events.
AnswersC, D

eventstats enriches each event with aggregate values calculated across the whole result set, appending fields like count or avg to every row. Unlike stats, it does not reduce events, so per-event detail remains alongside the computed aggregates.

Why this answer

Option C is correct because eventstats computes aggregate values (e.g., avg, sum, count) and then enriches each individual event with those results, effectively calculating the aggregate in the context of every event rather than collapsing them. Option D is correct because eventstats appends new fields containing the aggregate values to all events in the result set, preserving the original events while adding the computed statistics. Options A, B, and E are incorrect: eventstats is generally slower than stats because it must retain and enrich every event rather than reducing the result set; it does not remove non-aggregated fields (that describes stats behavior); and it does not replace existing events, it augments them.

Exam trap

SPLK-1004 often tests the confusion between 'stats' and 'eventstats', particularly the misconception that 'eventstats' removes fields or replaces events, when it actually adds aggregate fields to all events.

6
MCQmedium

A Splunk power user needs to calculate the total number of events per sourcetype and include a column that shows the percentage of total events each sourcetype represents. The search should return a table with sourcetype, count, and percentage. Which sequence of commands achieves this?

A.stats count BY sourcetype | eventstats sum(count) AS total | eval percentage = round((count/total)*100, 2) | table sourcetype count percentage
B.stats count BY sourcetype | eventstats sum(count) AS total BY sourcetype | eval percentage = round((count/total)*100, 2) | table sourcetype count percentage
C.stats count BY sourcetype | streamstats sum(count) AS total | eval percentage = round((count/total)*100, 2) | table sourcetype count percentage
D.stats count BY sourcetype | addtotals | eval percentage = round((count/total)*100, 2) | table sourcetype count percentage
AnswerA

The stats command calculates the count per sourcetype. The eventstats command then adds a field total containing the sum of all counts across the result set. The eval command computes the percentage using count divided by total, multiplied by 100 and rounded. Finally, table displays the desired columns, producing the correct output.

Why this answer

To calculate a percentage of total, the search must first aggregate counts per sourcetype using stats, then compute the grand total across all results using eventstats without a BY clause. The eval command then divides each count by the grand total and multiplies by 100. This sequence ensures each row's percentage is based on the overall total, not a running or grouped sum.

Exam trap

The trap here is confusing eventstats with streamstats or adding a BY clause to eventstats, which changes the scope of the aggregation from global to grouped.

7
MCQmedium

An analyst is reviewing web server logs and needs to display the top 5 URL paths by total bytes transferred. The field 'bytes' is numeric, and 'uri_path' is a string. Which search produces the correct result with the least performance impact?

A.index=web | eventstats sum(bytes) as total_bytes by uri_path | dedup uri_path | sort - total_bytes | head 5
B.index=web | top limit=5 bytes by uri_path
C.index=web | chart sum(bytes) over uri_path | sort - sum(bytes) | head 5
D.index=web | stats sum(bytes) as total_bytes by uri_path | sort - total_bytes | head 5
AnswerD

This search correctly aggregates the sum of bytes for each uri_path using stats, then sorts in descending order by total_bytes and returns the first five results with head. It avoids the overhead of commands like top or eventstats and directly answers the requirement of top 5 URL paths by total bytes transferred.

Why this answer

To find the top 5 URL paths by total bytes transferred, you need to sum the numeric bytes field for each uri_path and then sort descending. The stats command efficiently groups by uri_path and calculates the sum, producing a compact result set. Sorting and limiting with head gives the top 5.

This approach minimizes memory and processing compared to eventstats or chart, which retain more data or add overhead.

Exam trap

The trap here is confusing the top command with sorting by a metric; top ranks by frequency, not by the sum of a numeric field.

8
MCQhard

A Splunk administrator is building a dashboard panel that must show the total number of events per sourcetype and also include a column showing what percentage each sourcetype contributes to the overall event count. The search already uses stats count by sourcetype. Which approach will add the percentage column correctly in a single search?

A.Append | addtotals fieldname=total | eval pct=count/total*100
B.Append | eventstats sum(count) as total | eval pct=round(count/total*100,2)
C.Append | stats sum(count) as total | eval pct=round(count/total*100,2)
D.Append | top count by sourcetype | eval pct=percent
AnswerB

eventstats computes the sum of count across all result rows and adds it to each row as total, without collapsing the per-sourcetype rows. Dividing each count by that total and multiplying by 100 yields the percentage contribution for every sourcetype in one pass, which is exactly what the dashboard requires.

Why this answer

To add an aggregate value to every existing row without collapsing the result set, eventstats is the correct tool. It calculates the sum of the count field across all sourcetype rows and writes that total into each row. Dividing each row's count by the total and multiplying by 100 produces the percentage contribution while preserving the per-sourcetype breakdown needed for the panel.

Exam trap

The trap here is confusing eventstats with stats: stats collapses rows into a single total, while eventstats preserves the original rows and adds the aggregate alongside them.

9
MCQeasy

A Splunk user needs to add a field that indicates whether a response time is above or below a threshold of 500 milliseconds. The events contain a field named response_time. Which eval function should they use to create a new field called performance_category with values 'slow' or 'fast'?

A.eval performance_category=validate(response_time > 500, "slow", "fast")
B.eval performance_category=case(response_time > 500, "slow", "fast")
C.eval performance_category=coalesce(response_time > 500, "slow", "fast")
D.eval performance_category=if(response_time > 500, "slow", "fast")
AnswerD

The if function evaluates a condition and returns one value if true and another if false. Here, if response_time is greater than 500, it returns 'slow'; otherwise, it returns 'fast'. This directly creates the desired field with the correct classification based on the threshold.

Why this answer

The if function is the correct choice for a simple conditional that returns one of two values based on a boolean expression. It takes three arguments: condition, value if true, and value if false. This matches the requirement to classify response times as 'slow' or 'fast' based on a 500ms threshold.

Exam trap

The trap here is confusing if with case or coalesce, which serve different purposes and have different argument requirements.

10
MCQmedium

A power user wants to create a report that shows the average duration of each transaction, grouped by the 'service' field. The transactions are already grouped by a unique 'transaction_id' using the transaction command. Which command should be used next to calculate the average duration per service?

A.chart avg(duration) over service
B.timechart avg(duration) by service
C.stats avg(duration) as avg_duration by service
D.eventstats avg(duration) as avg_duration by service
AnswerC

After using the transaction command, each transaction has a 'duration' field. The stats command can then calculate the average of that duration field, grouped by the 'service' field. This produces the desired report of average transaction duration per service. It is efficient and straightforward.

Why this answer

After the transaction command creates transactions with a duration field, the stats command is ideal for aggregating that duration by service. It calculates the average duration for each service and outputs a concise table with one row per service. This is the most efficient and direct way to produce the required report, avoiding the extra events retained by eventstats or the time-based orientation of timechart.

Exam trap

The trap here is confusing eventstats with stats; eventstats adds the aggregate to each event, while stats summarizes into one row per group.

11
MCQmedium

You need to combine two fields into one string. Which eval function is used?

A.eval new = field1 + field2
B.eval new = field1 . field2
C.eval new = merge(field1, field2)
D.eval new = combine(field1, field2)
AnswerB

The concatenation operator in eval is the period, joining field1 and field2 into a single string value. Splunk's eval command uses the dot for string concatenation, so this expression produces the combined field. Functions such as strcat also concatenate, but the dot operator is the direct mechanism here.

Why this answer

In Splunk's eval command, string concatenation is performed with the dot (.) operator, so 'eval new = field1 . field2' correctly joins two field values into one string. The plus (+) operator is used for numeric addition, not string concatenation, and there is no built-in merge() or combine() eval function. This is a core SPL syntax rule tested frequently on SPLK-1004.

Exam trap

SPLK-1004 often tests the confusion between the + operator (numeric addition) and the . operator (string concatenation), catching candidates who assume + works for strings as in many programming languages.

How to eliminate wrong answers

Option A is wrong because the + operator performs arithmetic addition; if the fields are strings, it either errors or produces unexpected numeric coercion rather than concatenation. Option C is wrong because merge() is not a valid eval function in Splunk — no such function exists for combining strings. Option D is wrong because combine() is also not a Splunk eval function; candidates may confuse it with other platforms' string functions.

12
Multi-Selectmedium

Which TWO are common causes for a 'transaction' command taking too long?

Select 2 answers
A.The user is not an admin.
B.The number of unique group values is high.
C.The search spans too large a time range.
D.The data is in JSON format.
E.The search uses too few commands.
AnswersB, C

The transaction command groups events by shared field values, so many unique group values create numerous concurrent transactions held in memory. Each group requires its own state and matching work, inflating processing time and memory pressure.

Why this answer

Option B is correct because a high number of unique group values forces the search engine to create and track many distinct groups, which increases memory usage and processing time for the transaction command. Option C is correct because searching over a very large time range requires scanning more events, which directly increases the time needed to complete the transaction. Option A is incorrect because lacking admin privileges affects permissions, not transaction execution speed.

Option D is incorrect because JSON is simply a data format and does not inherently slow down a transaction. Option E is incorrect because using fewer commands would generally reduce, not increase, processing time.

Exam trap

SPLK-1004 often tests the misconception that transaction slowness is caused by data format or user permissions, when the real drivers are grouping cardinality and the volume of events scanned across the time range.

13
MCQmedium

You want to round a number in a field to two decimal places. Which function is used?

A.eval new_field = round(old_field, 2)
B.format new_field = 2
C.eval new_field = floor(old_field, 2)
D.eval new_field = ceil(old_field, 2)
AnswerA

The round function takes the numeric field and a precision argument, here 2, returning the value rounded to two decimal places. This directly satisfies the requirement to round a field to two decimal places within an eval expression.

Why this answer

The eval command's round function rounds a numeric field to a specified number of decimal places. The syntax eval new_field = round(old_field, 2) takes the value in old_field and rounds it to two decimal places, storing the result in new_field. This is the standard SPL approach for decimal rounding.

Exam trap

SPLK-1004 often tests whether candidates confuse round with floor and ceiling — the trap is picking floor or ceil because they sound like rounding functions, but they only round to integers and do not accept a decimal-places argument.

How to eliminate wrong answers

Option B is wrong because 'format new_field = 2' is not valid SPL syntax — format is not a command for numeric rounding, and assigning a literal 2 does not round anything. Option C is wrong because floor(old_field, 2) is invalid syntax; floor takes a single argument and rounds down to the nearest integer, not to two decimal places. Option D is wrong because ceil(old_field, 2) is also invalid syntax; ceil takes one argument and rounds up to the nearest integer, not to a specified decimal precision.

14
MCQmedium

How do you extract a portion of a string using 'eval'?

A.eval new = cut(old, 1, 5)
B.eval new = slice(old, 1, 5)
C.eval new = substr(old, 1, 5)
D.eval new = extract(old, 1, 5)
AnswerC

The substr function extracts characters by position and length, so substr(old, 1, 5) returns five characters starting at index 1. This directly satisfies the requirement to extract a portion of a string within an eval expression.

Why this answer

Splunk's eval command supports the substr() function, which extracts a substring from a string given a starting position (1-based) and length. The syntax eval new = substr(old, 1, 5) returns the first five characters of the 'old' field, making C the correct answer.

Exam trap

SPLK-1004 often tests the confusion between Splunk's substr() and similar-sounding functions from other languages (slice, cut, extract) — candidates pick the function name that 'sounds right' rather than the one Splunk actually implements.

How to eliminate wrong answers

Option A is wrong because 'cut' is not a valid eval function in Splunk — cut is not part of the eval function library at all. Option B is wrong because 'slice' is not a Splunk eval function; while some languages use slice(), Splunk uses substr(). Option D is wrong because 'extract' is not an eval function — Splunk has an 'extract' command for field extraction, but it is not used inside eval to slice strings.

15
MCQmedium

A security analyst wants to display a table of failed login attempts where the source IP field is shown as a clickable link that opens an external threat intelligence lookup page. The URL should embed the src_ip value, for example https://threatintel.example.com/lookup?ip=192.0.2.1. Which Splunk command and syntax should the analyst use to replace the src_ip field with the hyperlink while keeping the original field name in the results?

A.replace src_ip WITH "https://threatintel.example.com/lookup?ip=" . src_ip
B.eval src_ip = link("https://threatintel.example.com/lookup?ip=" . src_ip)
C.eval src_ip = "<a href=\"https://threatintel.example.com/lookup?ip=" . src_ip . "\">" . src_ip . "</a>"
D.eval src_ip = "https://threatintel.example.com/lookup?ip=" . src_ip
AnswerC

This builds an HTML anchor tag by concatenating the opening tag, the URL with the embedded src_ip, the closing quote and angle bracket, the visible link text, and the closing anchor tag. When the field is displayed in a results table, Splunk renders the HTML, making the IP a clickable link to the threat intelligence page while preserving the src_ip field name.

Why this answer

To turn a field value into a clickable hyperlink in Splunk results, the field must contain HTML anchor markup. The eval command can build that markup by concatenating the opening anchor tag, the URL with the embedded field value, the link text, and the closing tag. Overwriting the original field name keeps the table column labeled src_ip while the cell content becomes a working link to the external lookup page.

Exam trap

The trap here is assuming that simply concatenating a URL prefix with a field value produces a clickable link, when Splunk requires explicit HTML anchor markup for the field to render as a hyperlink.

16
MCQhard

A Splunk analyst is reviewing authentication logs and wants to reduce noise by showing only the first and last event for each user session, where a session is defined by a user field and a 30-minute inactivity timeout. The analyst also wants to include the total duration of each session. Which command should be used?

A.transaction user maxspan=30m
B.transaction user maxpause=30m
C.streamstats window=30 by user
D.stats min(_time) max(_time) by user
AnswerB

The transaction command with maxpause groups events for the same user into a session as long as the gap between consecutive events does not exceed 30 minutes. It also automatically adds duration and eventcount fields, so the analyst gets the session duration and can identify the first and last events of each session.

Why this answer

The transaction command is designed to group related events into sessions and supports maxpause to split when the time between events exceeds a threshold. Setting maxpause=30m and grouping by user creates sessions that end after 30 minutes of inactivity. transaction also adds duration and eventcount fields automatically, giving the analyst the session duration and the ability to identify first and last events.

Exam trap

The trap here is confusing maxspan with maxpause: maxspan limits total session length, while maxpause splits sessions on inactivity gaps.

17
Multi-Selectmedium

A Splunk power user is creating a report that requires calculating the running total of sales amounts over time, and also needs to include the overall average sales amount for each region on every row. Which two commands can be used together to achieve this? (Choose two.)

Select 2 answers
A.eventstats
B.stats
C.addtotals
D.transaction
E.streamstats
AnswersA, E

The 'eventstats' command computes aggregations across all events and adds the results to each event as a new field. Here, 'eventstats avg(sales_amount) as region_avg by region' would add the average sales amount per region to every row, satisfying the requirement to include the overall average on each row. It does not collapse events, so it works well alongside 'streamstats' for the running total.

Why this answer

To calculate a running total of sales amounts, 'streamstats' is the appropriate command because it processes events sequentially and can compute cumulative sums. To include the overall average sales amount per region on every row, 'eventstats' is needed because it calculates aggregations across all events and appends the result to each event without collapsing them. Used together, they provide both the running total and the per-region average on each row, meeting the report's requirements.

Exam trap

The trap here is confusing 'eventstats' with 'stats'; 'eventstats' preserves individual events and adds aggregate fields, while 'stats' collapses events, making it impossible to show both individual rows and aggregates simultaneously.

18
MCQmedium

A security analyst needs to enrich raw firewall logs by attaching the matching department name from a lookup table. The lookup table contains department IDs, and the firewall logs contain a field called dept_id. The analyst wants to add the department name to each event without discarding events that have no matching department ID. Which command should be used?

A.append
B.join
C.lookup
D.transaction
AnswerC

The lookup command enriches events by matching a field in the event to a field in a lookup table. By default, events without a match are retained, and the new field is simply null. This satisfies the requirement to add department names without dropping unmatched events.

Why this answer

The lookup command is specifically designed to enrich events with fields from an external lookup table. It matches on a field such as dept_id and adds the corresponding department name. By default, it retains events with no match, which aligns with the requirement to not discard unmatched events.

Exam trap

The trap here is confusing lookup with join, assuming that join is needed to combine data from two sources, when lookup is the correct tool for enriching events without losing unmatched ones.

19
MCQhard

When using 'stats', how does the 'values()' function differ from 'list()'?

A.Values() returns unique values, list() returns all values.
B.List() sorts the data automatically.
C.Values() is faster than list().
D.Values() is only for numbers.
AnswerA

values() deduplicates results, returning each distinct field value once, whereas list() preserves every occurrence including duplicates and maintains order. This distinction matters when counting unique entities versus inspecting the full multiset of raw values returned by the stats aggregation.

Why this answer

In Splunk's stats command, values() returns the unique (deduplicated) values of a field, while list() returns all values including duplicates. Both preserve order of appearance by default, but only values() removes duplicates. This distinction matters when counting distinct items versus listing every occurrence.

Exam trap

SPLK-1004 often tests the values() vs list() distinction, and the trap is assuming list() sorts or that values() is just a faster list() rather than a deduplicating function.

How to eliminate wrong answers

Option B is wrong because list() does not automatically sort data — it preserves the order in which values appear unless you apply sort afterward. Option C is wrong because values() is not inherently faster than list(); deduplication adds overhead, so performance depends on cardinality and data volume. Option D is wrong because values() works on any field type, not just numbers — it returns unique string, numeric, or other values.

20
MCQmedium

A power user needs to calculate the difference between the current value of a field 'cpu_load' and its value from the previous event, grouped by 'host'. The events are sorted by time. Which command accomplishes this?

A.streamstats current=f window=1 values(cpu_load) as prev_load by host | eval cpu_diff = cpu_load - prev_load
B.eval cpu_diff = cpu_load - lag(cpu_load) by host
C.delta cpu_load as cpu_diff
D.delta cpu_load as cpu_diff by host
AnswerD

The delta command calculates the difference between the current and previous value of a numeric field. By adding 'by host', it resets the calculation for each host, ensuring that the difference is computed only between consecutive events of the same host. This directly provides the required cpu_diff per host without additional commands.

Why this answer

The delta command is specifically designed to compute the difference between the current and previous value of a field. When used with a BY clause, it calculates the delta independently for each group, such as each host. This matches the requirement to calculate the change in cpu_load per host between consecutive events.

It is efficient and avoids the complexity of streamstats or invalid eval functions.

Exam trap

The trap here is forgetting the BY clause with delta, which would mix values from different hosts and yield incorrect differences.

21
MCQeasy

Which command sorts results by a field in descending order?

A.sort desc(field)
B.sort field=desc
C.sort field
D.sort -field
AnswerD

The sort command orders results by the specified field, and prefixing the field with a minus sign reverses the ordering to descending. So sort -field returns the highest values first, satisfying the requirement without needing any additional function or clause.

Why this answer

In Splunk SPL, prefixing a field name with a minus sign in the sort command sorts that field in descending order, so 'sort -field' is correct. Ascending order is the default and uses no prefix, while a plus sign explicitly requests ascending. This is a fundamental SPL syntax rule tested on SPLK-1004.

Exam trap

SPLK-1004 often tests the minus-sign convention for descending sort, catching candidates who expect SQL-style 'DESC' keywords or function wrappers like desc(field).

How to eliminate wrong answers

Option A is wrong because 'sort desc(field)' is not valid SPL syntax — desc() is not a sort modifier in Splunk. Option B is wrong because 'sort field=desc' treats 'field=desc' as a field name or comparison, not a sort direction indicator. Option C is wrong because 'sort field' sorts ascending by default, which is the opposite of what the question requires.

22
MCQmedium

A Splunk user has a search that returns events with a field named status_code containing values like 200, 404, and 500. The user wants to create a new field named status_category that contains the text Success for 200, Client Error for 4xx codes, and Server Error for 5xx codes, without removing the original status_code field. Which eval expression accomplishes this?

A.eval status_category=if(status_code==200, "Success", "Error")
B.eval status_category=case(status_code==200, "Success", status_code>=400 AND status_code<500, "Client Error", status_code>=500, "Server Error")
C.eval status_category=replace(status_code, "200", "Success")
D.eval status_category=coalesce(status_code, "Success", "Client Error", "Server Error")
AnswerB

The case function evaluates conditions in order and returns the value for the first true condition. This expression checks for 200, then the 4xx range, then the 5xx range, producing the correct category text while leaving the original status_code field intact for reference.

Why this answer

To map multiple numeric ranges to text labels, the case function is appropriate because it evaluates a list of condition-value pairs in order and returns the value for the first true condition. This allows 200 to map to Success, 4xx to Client Error, and 5xx to Server Error in a single eval, while the original status_code field remains available.

Exam trap

The trap here is reaching for if when multiple mutually exclusive conditions must be evaluated, since if only handles one condition and two outcomes.

23
MCQhard

You are correlating two searches. What is the primary advantage of using 'join' over 'lookup'?

A.Lookups cannot be used with stats.
B.Joins are faster than lookups.
C.Joins are automatically cached.
D.Joins allow for subsearch results to be mapped to the primary search results dynamically.
AnswerD

Join performs a subsearch and dynamically matches returned fields against events in the primary search at runtime, so correlation adapts to whatever the subsearch yields. Lookup instead matches against a static CSV or KV Store file, which cannot reflect live subsearch results.

Why this answer

The primary advantage of 'join' over 'lookup' is that join dynamically maps subsearch results to the primary search results at search time, allowing correlation based on matching field values without pre-building a lookup table. Lookups, by contrast, require a static or pre-defined external table. This dynamic mapping is the key differentiator.

Exam trap

SPLK-1004 often tests the misconception that joins are faster or cached, when the real advantage is dynamic subsearch mapping versus static lookup tables.

How to eliminate wrong answers

Option A is wrong because lookups can be used with stats; there is no inherent restriction preventing their combination. Option B is wrong because joins are generally slower than lookups, not faster, due to subsearch execution and result limits. Option C is wrong because joins are not automatically cached; lookups can be cached, but join does not have automatic caching.

24
MCQhard

A Splunk power user is building a search that needs to calculate the difference in seconds between two epoch time fields, start_time and end_time, and then format the result as a human-readable duration like '1h 23m 45s'. The fields are numeric epoch values. Which eval expression accomplishes this?

A.eval duration = end_time - start_time | convert dur2sec(duration)
B.eval duration = round(end_time - start_time, 0) . " seconds"
C.eval duration = tostring(end_time - start_time, "duration")
D.eval duration = strftime(end_time - start_time, "%Hh %Mm %Ss")
AnswerC

The tostring function with the "duration" format converts a numeric seconds value into a human-readable duration string such as '1h 23m 45s'. Subtracting start_time from end_time yields the difference in seconds, which tostring then formats appropriately. This is the correct and efficient way to achieve the desired output.

Why this answer

The tostring function in Splunk supports a "duration" format that converts a numeric seconds value into a human-readable string like '1h 23m 45s'. By subtracting the start_time from end_time, the eval command produces the difference in seconds, which tostring then formats correctly. This approach is straightforward and leverages built-in formatting capabilities.

Exam trap

The trap here is confusing strftime, which formats epoch timestamps, with tostring's duration format, which formats elapsed seconds into a readable duration.

25
MCQmedium

What is the result of 'transaction' command compared to 'stats'?

A.Transaction is for reporting only.
B.Transaction is always faster than stats.
C.Transaction groups events by time and common fields.
D.Stats can only be used with time.
AnswerC

Transaction aggregates related events into grouped results using a maximum pause between events plus shared field values, whereas stats computes aggregations across all matching events without temporal grouping. This satisfies the stem's comparison by identifying time-and-field correlation as the defining mechanism that separates transaction from stats.

Why this answer

The transaction command groups events that share common field values (like a session ID or transaction ID) and occur within a maximum time span (maxspan) or pause between events (maxpause), producing one row per transaction. In contrast, stats aggregates events into metrics (count, avg, sum) grouped by fields, without the time-bounded grouping semantics.

Exam trap

SPLK-1004 often tests the assumption that transaction is just a faster or reporting-only version of stats — candidates miss that transaction's defining feature is time-bounded grouping by common fields, not aggregation.

How to eliminate wrong answers

Option A is wrong because transaction is not limited to reporting — it is a search command used for grouping events into transactions for analysis, correlation, and even alerting. Option B is wrong because transaction is generally slower and more memory-intensive than stats, since it must track and group events across time windows. Option D is wrong because stats is not restricted to time — it can group by any field (host, user, status) and does not require a time field.

26
MCQhard

A security analyst needs to correlate failed login attempts with subsequent successful logins for the same user within 10 minutes. The relevant events are in the 'auth' index with fields 'user', 'action' (failed or success), and '_time'. Which command should be used to achieve this correlation?

A.stats count by user, action | where action="failed" AND action="success"
B.transaction user maxspan=10m startswith=action="failed" endswith=action="success"
C.join user [ search index=auth action=success ]
D.eventstats values(action) as actions by user | where mvcount(actions)>1
AnswerB

The transaction command groups events that share a common field (user) and are within a specified time span (maxspan=10m). By specifying startswith and endswith, it defines the boundaries of the transaction, allowing the analyst to find sequences where a failed login is followed by a successful login within 10 minutes. This directly addresses the correlation requirement.

Why this answer

The transaction command is designed to group related events into a single transaction based on a common field and time constraints. By specifying startswith and endswith, it ensures that only sequences beginning with a failed login and ending with a successful login within 10 minutes are grouped. This precisely matches the analyst's need to correlate failed attempts with subsequent successful logins for the same user.

Exam trap

The trap here is assuming that stats or eventstats can enforce temporal order and window, but they aggregate without respecting event sequence or time bounds.

27
MCQeasy

Which command is used to remove a field from the search results?

A.eval field_name = null
B.fields - field_name
C.drop field_name
D.delete field_name
AnswerB

The fields command with a minus sign removes the named field from results, using the same field-selection syntax as the plus form. This satisfies the requirement to strip a field from the returned events without altering the underlying indexed data.

Why this answer

The fields command with a minus sign (fields - field_name) is used to remove a field from search results. This command explicitly excludes the specified field from the output, which is the correct way to drop a field in SPL. It is a standard part of the Splunk search processing language for field manipulation.

Exam trap

SPLK-1004 often tests whether candidates confuse field removal with field nullification or with event deletion, tempting them to choose eval with null or a non-existent command like drop.

How to eliminate wrong answers

Option A is wrong because eval field_name = null assigns a null value to the field but does not remove it from the results — the field still exists with a null value, which is different from removing it entirely. Option C is wrong because 'drop' is not a valid Splunk SPL command for removing fields; it is a SQL command and does not exist in Splunk's search language. Option D is wrong because 'delete' in Splunk is used for deleting events from an index (with the delete command), not for removing a field from search results.

28
MCQhard

How do you handle case-insensitive filtering in a 'where' clause?

A.where field == /value/i
B.where lower(field) = "value"
C.where field = '(?i)value'
D.where field.case = "ignore"
AnswerB

Wrapping the field in lower() normalises its case before comparison, so values differing only in capitalisation still match. This satisfies the case-insensitive filtering requirement, which a plain equality test against the raw field cannot achieve.

Why this answer

Splunk's where command uses eval-style expressions, and the correct way to perform case-insensitive comparison is to normalize the field with lower() (or upper()) and compare against a lowercase literal. The syntax where lower(field) = "value" is valid eval expression syntax and reliably matches regardless of case.

Exam trap

SPLK-1004 often tests whether candidates confuse eval expression syntax with regex syntax — the trap is picking the regex-flag option (A or C) because it looks like a familiar case-insensitive pattern, when where actually requires eval functions.

How to eliminate wrong answers

Option A is wrong because where does not support regex literal syntax like /value/i — that is a Perl/JavaScript regex idiom, not Splunk SPL. Option C is wrong because where does not accept inline regex flags such as '(?i)value' as a comparison operand; regex matching in Splunk uses match() or the regex command, not this syntax. Option D is wrong because there is no field.case attribute or 'ignore' modifier in Splunk SPL — this is fabricated syntax.

29
Multi-Selecthard

Which THREE of the following functions are used with 'stats' to aggregate data?

Select 3 answers
A.max
B.count
C.eval
D.search
E.sum
AnswersA, B, E

The max function is a statistical aggregation function used with stats to return the highest value of a numeric field across each group, satisfying the stem's requirement for functions that aggregate data rather than evaluate or format it.

Why this answer

The 'stats' command in Splunk aggregates events and supports statistical functions such as max, count, and sum. Option A (max) is correct because max returns the highest value of a numeric field across the grouped events. Option B (count) is correct because count tallies the number of events in each group, which is a core aggregation.

Option E (sum) is correct because sum adds the values of a numeric field across events in each group. Option C (eval) is not a stats function; it is a separate command used to calculate or transform field values. Option D (search) is also not a stats function; it is a command used to filter events, not to aggregate them.

Exam trap

SPLK-1004 often tests whether candidates can distinguish stats aggregation functions from commands like eval and search that appear in the same SPL pipeline — the trap is picking eval because it is frequently seen alongside stats.

30
MCQhard

What is the limitation of using 'join' in a search?

A.Joins only work on numerical fields.
B.Joins are deprecated in Splunk.
C.Joins cannot be used with subsearches.
D.The subsearch result limit is 100 by default.
AnswerD

The join subsearch returns at most 100 results by default, so any larger result set is silently truncated, potentially dropping matches. Raising maxout or using alternative correlation commands avoids this ceiling when the subsearch is expected to exceed that limit.

Why this answer

The join command in Splunk runs a subsearch to build the right-hand dataset, and that subsearch is capped at 100 results by default (controlled by the maxout setting, which defaults to 100). This means any join whose subsearch returns more than 100 rows will silently truncate, producing incomplete or misleading results. This is the primary practical limitation of join and the reason Splunk recommends alternatives like stats, lookup, or append when working with large datasets.

Exam trap

SPLK-1004 often tests the specific default value of the join subsearch limit (100) and the misconception that join is deprecated or restricted to numeric fields, when the real limitation is the subsearch result cap.

How to eliminate wrong answers

Option A is wrong because join works on any field type, not just numerical fields — it matches on string, numeric, or any other field values. Option B is wrong because join is not deprecated in Splunk; it remains a supported command, though Splunk documentation recommends stats-based alternatives for performance reasons. Option C is wrong because join absolutely can be used with subsearches — in fact, join requires a subsearch as its right-hand argument, so this statement is the opposite of reality.

31
MCQeasy

How do you add a total row to a stats table?

A.addsum
B.eval total = sum(field)
C.addtotals
D.stats total
AnswerC

The addtotals command appends a summary row aggregating the numeric columns of the preceding results, producing the total row beneath a stats table. It satisfies the stem's requirement directly, unlike eventstats or appendpipe, which do not add a totals row.

Why this answer

The `addtotals` command is specifically designed to append a summary row (or column) to the results of a statistical aggregation, such as those produced by `stats` or `chart`. It computes the sum of each numeric field across all result rows and adds a new row labeled 'Total' at the bottom. This is the standard SPL approach for adding totals to a stats table without altering the underlying aggregation logic.

Exam trap

SPLK-1004 often tests the distinction between commands that add summary rows versus those that perform aggregation, and candidates may confuse `addtotals` with `stats sum()` or invalid commands like `addsum`.

How to eliminate wrong answers

Option A is wrong because `addsum` is not a valid Splunk Search Processing Language (SPL) command; there is no such command in Splunk. Option B is wrong because `eval total = sum(field)` attempts to create a new field using an eval function, but `sum` is an aggregation function that only works within transforming commands like `stats`, not within `eval`; using it in eval will result in an error or unexpected behavior. Option D is wrong because `stats total` is not a valid syntax; `stats` requires an aggregation function (e.g., `sum(field)`) and does not have a built-in 'total' function to add a total row.

32
Multi-Selecthard

Which THREE of the following are valid aggregation functions used with 'stats'?

Select 3 answers
A.dc
B.where
C.avg
D.count
E.rename
AnswersA, C, D

The `dc` function returns the count of distinct values in a field, satisfying the need for a valid `stats` aggregation. Unlike `count`, which totals all events, `dc` deduplicates before counting, making it essential for measuring unique occurrences such as distinct users or hosts within Splunk searches.

Why this answer

The 'stats' command in Splunk supports aggregation functions such as dc (distinct count), avg (average), and count, so options A, C, and D are all valid. Option A, dc, is correct because it returns the number of distinct values for a field, e.g., 'stats dc(user)'. Option C, avg, is correct because it computes the arithmetic mean of a numeric field, e.g., 'stats avg(response_time)'.

Option D, count, is correct because it counts the number of events or occurrences, e.g., 'stats count by host'. Option B, where, is not an aggregation function; it is a filtering command used to filter search results based on a condition. Option E, rename, is not an aggregation function; it is a command used to rename fields in the results.

Exam trap

SPLK-1004 often tests the confusion between aggregation functions and other SPL commands. Candidates might mistakenly think 'where' or 'rename' can be used as aggregation functions because they appear in search pipelines.

33
MCQeasy

How do you calculate the percentage of total events for each status code?

A.stats count by status | eventstats sum(count) as total | eval percent = (count/total)*100
B.stats count(status) as total
C.stats count by status | eval percent = count/total
D.chart count by status | addtotals
AnswerA

eventstats computes the sum of all per-status counts and appends that total to every row, letting eval divide each count by the grand total and multiply by 100. This yields each status code's percentage of all events without collapsing the per-status breakdown.

Why this answer

The correct answer uses stats count by status to get counts per status, then eventstats sum(count) as total to compute the total across all events, and finally eval percent = (count/total)*100 to calculate the percentage. This is the standard Splunk pattern for percentage-of-total calculations because eventstats adds the aggregate total to each row without collapsing results. The combination ensures each status code's percentage is correctly derived from the overall event count.

Exam trap

SPLK-1004 often tests the difference between stats and eventstats; candidates frequently forget that eventstats is needed to add the total to each row, and mistakenly try to use stats alone or assume eval can reference an undefined total.

How to eliminate wrong answers

Option B is wrong because stats count(status) as total only returns a single total count of all events, not a breakdown by status code, so it cannot produce per-status percentages. Option C is wrong because it attempts to divide count by total, but total is not defined in that search; without eventstats or a subsearch to compute the sum, the eval will fail or produce incorrect results. Option D is wrong because chart count by status | addtotals only adds a total row or column to the chart output; it does not calculate percentages for each status code.

34
MCQhard

What is the purpose of 'streamstats' compared to 'stats'?

A.It computes aggregates for each event based on current and previous events.
B.It can only be used with time-series data.
C.It is faster for large datasets.
D.It computes aggregates over the entire search result set.
AnswerA

streamstats computes aggregates incrementally, adding each event's values to the running calculation as the search progresses, so every event carries a result reflecting itself and all preceding events. stats instead collapses the whole result set into one row per group.

Why this answer

The streamstats command computes cumulative, running aggregates as it processes events in order, meaning each event's result reflects the current event plus all preceding events in the stream. In contrast, stats collapses the entire result set into a single aggregate row per grouping (or one row total), losing per-event granularity. This makes streamstats ideal for running totals, moving averages, and cumulative counts.

Exam trap

SPLK-1004 often tests the distinction between per-event running aggregates (streamstats) and whole-result-set aggregates (stats), so candidates who assume streamstats is just a faster stats pick the wrong option.

How to eliminate wrong answers

Option B is wrong because streamstats is not restricted to time-series data — it works on any ordered event stream regardless of whether a time field is present. Option C is wrong because streamstats is generally not faster than stats; it processes events sequentially and maintains state, so it can be slower and more memory-intensive on large datasets. Option D is wrong because computing aggregates over the entire result set is precisely what stats does, not streamstats — streamstats produces a value per event based on the running window.

35
MCQeasy

You want to see a list of unique 'clientip' addresses. Which command is most efficient?

A.stats count by clientip
B.head 100
C.dedup clientip
D.chart clientip
AnswerC

The dedup command removes duplicate events sharing identical values in the specified field, so dedup clientip returns one event per unique address. It is more efficient than sort plus uniq because dedup stops processing once it has seen each distinct value, avoiding a full sort of the result set.

Why this answer

The dedup command is specifically designed to remove duplicate events based on specified fields, making it the most efficient way to get a list of unique clientip addresses. It returns the first occurrence of each unique value and is optimized for this purpose. While stats count by clientip also provides unique values, it includes counts and may be less efficient for simply listing unique IPs, especially when you don't need the counts.

Exam trap

SPLK-1004 often tests the difference between dedup and stats for uniqueness; candidates may choose stats count by because they think it's always more efficient, but dedup is specifically optimized for returning unique values without counts.

How to eliminate wrong answers

Option A is wrong because stats count by clientip returns a table of unique clientip values along with their counts, which is more data than needed and may be less efficient if you only want the list of unique IPs. Option B is wrong because head 100 simply returns the first 100 events, not unique clientip addresses; it does not deduplicate. Option D is wrong because chart clientip is not a valid Splunk command; chart requires an aggregation function like count, and even if used correctly, it would produce a chart, not a simple list of unique values.

36
MCQhard

What is the difference between 'chart' and 'timechart'?

A.Timechart automatically buckets by time.
B.They are identical commands.
C.Chart is for time-based data.
D.Timechart is for non-time fields.
AnswerA

Unlike chart, which plots results against the existing _time field without altering it, timechart implicitly applies binning to _time, grouping events into equal time buckets and producing a time-series table. This automatic bucketing satisfies the requirement to aggregate metrics over consistent intervals.

Why this answer

The key difference is that timechart automatically buckets events by time and plots the results over time, while chart does not automatically bucket by time and can be used with any field. Timechart is specifically designed for time-series visualizations.

Exam trap

SPLK-1004 often tests the automatic time bucketing feature of timechart versus the flexibility of chart, causing candidates to confuse their primary purposes or assume they are interchangeable.

How to eliminate wrong answers

Option B is wrong because chart and timechart are not identical; timechart includes automatic time bucketing and a time axis, while chart does not. Option C is wrong because chart is not specifically for time-based data; it can be used with any field, and timechart is the one that handles time. Option D is wrong because timechart is for time-based data, not for non-time fields; it requires a time field and buckets by time.

37
Multi-Selectmedium

Which TWO of the following commands are considered 'transforming' commands?

Select 2 answers
A.timechart
B.stats
C.rex
D.fields
E.where
AnswersA, B

The timechart command is transforming because it groups events into time buckets and aggregates them, returning a table of statistics rather than the original events. This satisfies the stem's criterion of a transforming command, alongside stats.

Why this answer

In Splunk's Search Processing Language (SPL), transforming commands are those that order the results into a data table, typically aggregating or grouping events into statistical output — and both A (timechart) and B (stats) do exactly this. The timechart command is a transforming command because it aggregates events into a time-series table, bucketing by _time and splitting by a field to produce statistical values per time interval. The stats command is likewise transforming because it computes aggregations (such as count, sum, avg, dc) and returns a tabular result set grouped by specified by-clauses.

By contrast, C (rex) is a field-extraction command that only adds fields to events without restructuring them into a table, D (fields) is a filtering/field-selection command that includes or excludes fields, and E (where) is a filtering command that evaluates a boolean expression to keep or drop events — none of these transform the result set into statistical tabular output.

Exam trap

SPLK-1004 often tests the distinction between transforming commands (which aggregate/restructure) and streaming commands (which filter/process events), so candidates mistakenly pick rex or where because they 'change' the data in some way.

38
Multi-Selectmedium

Which TWO actions can be performed by the 'eval' command?

Select 2 answers
A.Creating new data inputs
B.Concatenating strings
C.Performing mathematical calculations
D.Changing user permissions
E.Removing events from the index
AnswersB, C

The eval command builds new fields from expressions, and its concatenation operator (plus sign) joins string values or field contents into a single result. This satisfies the stem's requirement that eval can concatenate strings, alongside its other calculation and conversion capabilities.

Why this answer

Option B is correct because the eval command can concatenate strings using functions such as + or the concatenation operator, for example eval full_name = first_name . " " . last_name, which builds a new field from existing string values. Option C is correct because eval is specifically designed to perform mathematical calculations, such as eval total = price * quantity, using arithmetic operators and functions like round() or abs(). The other options do not belong: eval does not create new data inputs (that is done by inputs.conf or data ingestion), it cannot change user permissions (that is handled by role and user management), and it cannot remove events from the index (that requires delete or index management commands).

Exam trap

SPLK-1004 often tests the distinction between eval and other commands like where, search, and stats, causing candidates to confuse eval's field manipulation capabilities with data input or permission management.

39
MCQhard

When using 'chart', what is the behavior if you do not specify a 'by' clause?

A.It returns an error.
B.It creates a single-series chart for the entire result set.
C.It defaults to the first field found.
D.It returns the same as 'stats'.
AnswerB

Omitting the 'by' clause collapses all results into one aggregation group, so 'chart' renders a single series spanning the whole result set rather than splitting values across multiple series. This satisfies the stem's constraint of no split-by field being supplied, producing one aggregated series instead of per-category series.

Why this answer

When you use the chart command without a 'by' clause, Splunk produces a single-series chart that aggregates the entire result set into one row/series. The chart command requires at least one aggregation function (e.g., count, sum) and without a 'by' clause it simply applies that function to all events, returning one data point per aggregation.

Exam trap

SPLK-1004 often tests whether candidates think chart requires a 'by' clause or errors without one, when it actually returns a single-series result.

How to eliminate wrong answers

Option A is wrong because chart does not error out without a 'by' clause; it returns a valid single-series result. Option C is wrong because chart does not default to the first field found — it uses the specified aggregation function, not an arbitrary field. Option D is wrong because chart and stats are not equivalent; chart is specifically for creating tabular/chartable output and requires an aggregation, while stats is more general and can return multiple fields without a 'by' clause.

40
MCQeasy

You need to count the total number of unique users per department using the 'stats' command. Which command syntax is correct?

A.stats list(user) by department
B.stats values(user) by department
C.stats dc(user) by department
D.stats count(user) by department
AnswerC

dc(user) is the distinct count function, returning the number of unique user values. Grouping with by department produces one row per department, giving the unique user count for each, which is precisely what the requirement asks.

Why this answer

The dc() function in Splunk's stats command stands for 'distinct count' and returns the number of unique values for a field. 'stats dc(user) by department' correctly counts unique users per department. The other functions either list values, return the values themselves, or count all events rather than unique occurrences.

Exam trap

SPLK-1004 often tests the distinction between dc() (distinct count), values() (distinct values list), and count() (total event count), catching candidates who assume count() returns unique counts.

How to eliminate wrong answers

Option A is wrong because list(user) returns all values of user as a multivalue field, not a count of unique users. Option B is wrong because values(user) returns the distinct values themselves as a multivalue field, not the number of them. Option D is wrong because count(user) counts the total number of events where user is present, including duplicates, rather than unique users.

Ready to test yourself?

Try a timed practice session using only Transforming Commands And Formatting questions.