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!

Demo Day: Strengthen Your SOC with Splunk Enterprise Security 8.1

Today’s threat landscape is more complex than ever. Security operation centers (SOCs) are overwhelmed with ...

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...