Dashboards & Visualizations

Unable to output "index" field in Splunk table

POR160893
Builder

Hi,

I have a query that is searching over 4 different indexes (AIBA, AIBC, AIBP, AIBX) as follows:

index=AIB* "Windows" EventCode="*"

| stats count as NumOfLogs by dvc_NodeName
| sort - NumOfLogs
| eval Host = dvc_NodeName
| table Host , NumOfLogs, index

However, I need one of the fields on the outputted table to be "Index" but nothing is currently outputted in my current query.


Can you please help?


Thanks as always!



Labels (4)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @POR160893 ,

as @ITWhisperer said, after s stats command you have only the fields in the stats command.

If you want index, you have to add it to the stats, something like this:

index=AIB* "Windows" EventCode="*"
| stats values(index) AS index count AS NumOfLogs BY dvc_NodeName
| sort - NumOfLogs
| eval Host = dvc_NodeName
| table Host NumOfLogs index

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @POR160893 ,

as @ITWhisperer said, after s stats command you have only the fields in the stats command.

If you want index, you have to add it to the stats, something like this:

index=AIB* "Windows" EventCode="*"
| stats values(index) AS index count AS NumOfLogs BY dvc_NodeName
| sort - NumOfLogs
| eval Host = dvc_NodeName
| table Host NumOfLogs index

Ciao.

Giuseppe

ITWhisperer
SplunkTrust
SplunkTrust

The stats command reduces the fields to NumOfLogs and dvc_NodeName i.e index is no longer available beyond that point

Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...