Splunk Search

Using wildcard in fields command not working as expected

treywebb
Explorer

For example the following search continues to include fields that start with user (such as userName, userId) etc.

index=blah | fields - user*

Has anyone else seen this or am I just doing this wrong?

Tags (1)
0 Karma
1 Solution

aweitzman
Motivator

You will still see those fields in the raw data, Splunk doesn't change that. What does change are the fields it is keeping track of going forward.

For instance, your results for these two searches should be different:

index=blah | table *

and

index=blah | fields - user* | table *

Eliminating fields you don't need as you build your search string just means that Splunk internally doesn't keep them around anymore as it is generating your search results. Splunk never changes your raw data, only how it is interpreted.

View solution in original post

aweitzman
Motivator

You will still see those fields in the raw data, Splunk doesn't change that. What does change are the fields it is keeping track of going forward.

For instance, your results for these two searches should be different:

index=blah | table *

and

index=blah | fields - user* | table *

Eliminating fields you don't need as you build your search string just means that Splunk internally doesn't keep them around anymore as it is generating your search results. Splunk never changes your raw data, only how it is interpreted.

treywebb
Explorer

This explains it perfectly. I was overlooking _raw in the events tab. doing as you show here works as expected. Thanks!

0 Karma

woodcock
Esteemed Legend

I am skeptical of your claim. Just because the fields do not exist, does not mean that the data to which they used to point will be obliterated from your event (which is perhaps the mistaken assumption you are using to presume that the command isn't working). I will prove that the command works; try this:

index=blah | stats count by userName

This will surely give you data. Now try it after removing the fields like this:

index=blah | fields - user* | stats count by userName

This will surely yield no results.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...