Splunk Search

How to count/eval filter with tstats

ividence
Engager

Hello,

How to get a percent of "Success / Total" events in a DataModel with "status=success or failed":

  • Trying to count both with one tstat on the main namespace:
    | tstats count as Total count(eval(status=success)) as Success from datamodel=events where nodename=event

  • Trying to pipe results from 2 tstats:
    | tstats prestats=t count as Total from datamodel=events where nodename=event | tstats prestats=t append=t count as Success from datamodel=events where nodename=event event.status=success

  • Adding: is_success = 0 or 1 on each event in the base Datamodel (with an eval) ? no

Thanks for your help,

Tags (3)
0 Karma

Rocket66
Communicator

Try this:

| tstats count("event.status") AS Total sum("event.is_success") AS "Success" sum("event.is_failed") AS "Failed" from datamodel="events" where (nodename="event") | eval Percentage=round(((100/Total)*Success),2)

I hope, this will solve your problem,

Greetz, Robert

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...