Splunk Search

Why won't this table show new field names?

firstname
Explorer

Based on what I've studied, I should be able to show a new field named item with a search such as the one below:

index=existing_index | eval item = "apple" | stats count by source | table source, item, count

I would expect output similar to the table below.

source item count
a/b/123.log apple 5
a/c/915.log apple 6
a/b/574.log apple 1

 

Instead, this happens:

source item count
a/b/123.log   5
a/c/915.log   6
a/b/574.log   1

 

Why did I not get what I expected?

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

The stats command removes all fields not mentioned - try this

index=existing_index | eval subfolder = "apple" | stats values(subfolder) as subfolder count by source | table source, subfolder, count

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

The stats command removes all fields not mentioned - try this

index=existing_index | eval subfolder = "apple" | stats values(subfolder) as subfolder count by source | table source, subfolder, count

 

Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...