Splunk Search

Head not stopping the search

Didalready
Explorer

When I use the search below, the event is 25 days ago, set search to last 30 takes 10 seconds, set to 90 days takes 23 seconds. I thought head would stop the query? Server info: Splunk 9.4.4, deleted every thing after head but didnt help speed.

The search  search index=XXXX_wineventlog host="XXXX-AV-DC01" (EventCode=4724 OR EventCode=4738) user="krbtgt"
| head 1
| eval time_since_last_event = now() - _time
| eval duration = tostring(time_since_last_event, "duration")
| eval days = round(time_since_last_event / 86400)
| eval status = if(days > 92, "krbtgt not updated", "krbtgt updated")
| fieldformat _time = strftime(_time, "%Y-%m-%d %H:%M:%S")
| table host, EventCode, _time, duration, days, status

Labels (1)
Tags (1)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

When I use the search below, the event is 25 days ago, set search to last 30 takes 10 seconds, set to 90 days takes 23 seconds. I thought head would stop the query? Server info: Splunk 9.4.4, deleted

This is a misunderstanding of how head works.  From head:

The head command is a centralized streaming command. See Command types.

And from that reference:

A streaming command operates on each event as the event is returned by a search.

In other words, each returned event will go through head, just like how piped head works in Unix.  In general, SPL does not give subsequent pipe elements control over preceding elements; they simply process results from preceding pipe, just like in Unix.   Hope this helps.

View solution in original post

yuanliu
SplunkTrust
SplunkTrust

When I use the search below, the event is 25 days ago, set search to last 30 takes 10 seconds, set to 90 days takes 23 seconds. I thought head would stop the query? Server info: Splunk 9.4.4, deleted

This is a misunderstanding of how head works.  From head:

The head command is a centralized streaming command. See Command types.

And from that reference:

A streaming command operates on each event as the event is returned by a search.

In other words, each returned event will go through head, just like how piped head works in Unix.  In general, SPL does not give subsequent pipe elements control over preceding elements; they simply process results from preceding pipe, just like in Unix.   Hope this helps.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Word Search

This challenge was first posted on Slack #puzzles channelThis puzzle is based on a letter grid containing ...

[Puzzles] Solve, Learn, Repeat: Advent of Code - Day 4

Advent of CodeIn order to participate in these challenges, you will need to register with the Advent of Code ...

GA: S3 Promote for Historical Data Ingestion in Splunk Cloud

Ingest Historical S3 Data On-Demand: Announcing the General Availability of S3 Promote We’re excited to share ...