Splunk Search

Total Time in D:M:H:S- using appendpipe instead of totalseconds and display on Dashboard

Xe03kfp
Path Finder

I am trying to somehow get a total sum of the "Total Time" column and have it be on a separate line rather the next line because it adds totals of anything with a number. I found appendpipe to go to the next line.

Search string:

index="rdpg"
( 2222222 dest_port="") OR (1111111 src_port="") OR ( 1111111 src_ip="") OR (2222222 dest_ip="")
| eval disconnect_time=if(match(_raw,"2222222"),_time,null())
| eval connect_time=if(match(_raw,"1111111"),_time,null())
| eval Ephemeral=if(isnotnull(disconnect_time),dest_port,Ephemeral)
| eval Ephemeral=if(isnotnull(connect_time),src_port,Ephemeral)
| stats min(connect_time) as Connect max(disconnect_time) as Disconnect min(src_ip) as "Source IP" max(dest_ip) as "Destin ip" by Ephemeral
| eval Seconds=Disconnect-Connect | fieldformat Seconds=strftime('Seconds', "%s") | eval "Total Time"=tostring(Seconds,"duration") | where Seconds > 300
| search Connect=* Disconnect=* | appendpipe [stats sum(Seconds) as "Total Seconds" ]
| convert timeformat="%a %b-%d %Y "at" %H:%M:%S" ctime(Connect) ctime(Disconnect)

See results -=HERE=-

ALSO: If I have a dashboard and I can get this total time thing working... can I somehow have a "button" that displays the total time based on a timeframe I specify?

Here is my Dashboard and the "button" I'd like Example --The Red things 🙂

0 Karma
1 Solution

jonuwz
Influencer

change :

appendpipe [stats sum(Seconds) as "Total Seconds" ]

to :

appendpipe [stats sum(Seconds) as tseconds | eval tseconds=tostring(tseconds,"duration") | rename tseconds as "Total Time" ]

For the button stuff - how well do you know Advanced XML ?

What you'd normally do Is something like this :

HiddenSearch (not including the appendpipe )
|-SimpleResultsTable
|-PostProcess (just add | stats sum(Seconds) as tseconds etc etc )
  |-SingleValue

View solution in original post

jonuwz
Influencer

change :

appendpipe [stats sum(Seconds) as "Total Seconds" ]

to :

appendpipe [stats sum(Seconds) as tseconds | eval tseconds=tostring(tseconds,"duration") | rename tseconds as "Total Time" ]

For the button stuff - how well do you know Advanced XML ?

What you'd normally do Is something like this :

HiddenSearch (not including the appendpipe )
|-SimpleResultsTable
|-PostProcess (just add | stats sum(Seconds) as tseconds etc etc )
  |-SingleValue

jonuwz
Influencer

No problem - just a point of interest, buttons dont look like that in splunk 5 any more, thats a splunk 4 screenshot.

0 Karma

Xe03kfp
Path Finder

Thanks! Appendpipe fix worked! I will let you know about the XML after implement it 🙂 -YOU DA MANG!

0 Karma
Get Updates on the Splunk Community!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

Cisco Use Cases, ITSI Best Practices, and More New Articles from Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...