Splunk Search

How can we use tstats with TERM and PREFIX?

danielbb
Motivator

I'm trying to run - 

 

 

| tstats count where index=wineventlog* TERM(EventID=4688) by _time span=1m

 

 

It returns no results but specifying just the term's value seems to work - 

 

| tstats count where index=wineventlog* TERM(4624) by _time span=1m

 




https://conf.splunk.com/files/2020/slides/PLA1089C.pdf explains the subject well but my simple query is not working.

Labels (1)
0 Karma

schose
Builder

Hi @danielbb ,

 

It's EventCode, not EventID. 😉

| tstats count where index=wineventlog* TERM(EventCode=4688) by _time span=1m

 best regards,

 

Andreas

0 Karma

nordinethales
Path Finder

Hi danielbb,

You can try

| tstats count where index=wineventlog* TERM(EventID=*) by _time span=1m
But in the _raw event, you must have something which corresponds, like

...EventID=4624...


Then, if you want to use this EventID in the group by, you can try (be carefull The text you provide for the PREFIX() directive must be in lower case)

| tstats count where index=wineventlog* TERM(EventID=*) by PREFIX(eventid=) _time span=1m

Regards

neelwoolies
Engager

This is perfect. 

0 Karma

danielbb
Motivator

Ok, but TERM(4624) does work. 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Which means that term is stored in a tsidx file (is indexed).

---
If this reply helps you, Karma would be appreciated.

richgalloway
SplunkTrust
SplunkTrust

The tstats command only works with indexed fields, which usually does not include EventID.

---
If this reply helps you, Karma would be appreciated.
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
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, ...