Splunk Search

How to use custom key field in tstats?

GaryZ
Path Finder
I'm having trouble capturing the custom key - "UserKey_ABC" in the following script.   With the following code, I'm not able to see any results.  However, if I remove "UserKey_ABC", I am able to get the results.  I'm certain I do have this key in my events.  How do I approach this issue?
 
| tstats count where index=abc  Arguments.email=“myemail@abc.com" by 
                     device_build, Arguments.test_url, UserKey_ABC
                     
| rename UserKey_ABC.Day as day, 
                     UserKey_ABC.job1 as job1,
                     UserKey_ABC.Version as version, 
                     Arguments.test_url as test_url, 
                     device_build as build
                     
| table build, lib, day, job1, version, test_url
Labels (5)
0 Karma

GaryZ
Path Finder

@yuanliu I'm fairly new to Splunk this year.   Can you explain what you mean?  - "You can still use the fields in statistical functions"

I've tried 

| tstats count where index=abc  Arguments.email=“myemail@abc.com" by 
                     device_build, Arguments.test_url, UserKey_ABC.job1
 
| rename UserKey_ABC.Day as day, 
                     UserKey_ABC.job1 as job1
 
But that didn't work for me either.

Thanks.

0 Karma

yuanliu
SplunkTrust
SplunkTrust

That's because at index time (when Splunk ingests data), fields like UserKey_ABC.job1 doesn't exist.  They are extracted at search time by some mechanism, but do not exist in indexer.

0 Karma

yuanliu
SplunkTrust
SplunkTrust

tstats only operates on indexed fields.  You can still use the fields in statistical functions.  So, you need to define how you want to see these values, and you cannot use them in groupby.

 

0 Karma
Get Updates on the Splunk Community!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...