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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...