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 Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...