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!

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...