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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...