Splunk Search

Expanding data within my eval search

AttarSingh1
Explorer

index=data severity IN ("critical","high","medium","low")
| eval TopHost =
[ search index=tenable severity IN ("critical","high","medium","low")
| where len(dnsName)>0
| dedup dnsName,solution
| dedup dnsName,pluginText
| rex field=pluginName "^(?<VulnName>(?:\w+\s+){2})"
| dedup dnsName,VulnName
| top limit=1 dnsName
| rename dnsName as query
| fields query
| head 1]


| where dnsName=TopHost
| table dnsName, ip

 

My query above works, but missing one thing. Right now it is getting the first result ( using head command ). I am trying to do first 5 results and store that to my eval variable. I tried to change head 5 but got errors. Any help is appreciated. Thanks

Attached error

Labels (4)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

index=data severity IN ("critical","high","medium","low")
| eval TopHost =
split([ search index=tenable severity IN ("critical","high","medium","low")
| where len(dnsName)>0
| dedup dnsName,solution
| dedup dnsName,pluginText
| rex field=pluginName "^(?<VulnName>(?:\w+\s+){2})"
| dedup dnsName,VulnName
| top limit=1 dnsName
| rename dnsName as query
| fields query
| head 5
| format "\"" "" "" "" "" "\""]," ")
| where dnsName=TopHost
| table dnsName, ip

This assumes dnsName has no spaces in it

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...