Splunk Search

How to get sum and charts of usage time values for corresponding fields?

fziegler
New Member

I'm using splunk 6.0.3

When I search for: "has been closed after being in use"
I have a series of hits like shown in the 4 sample lines below:

2014-06-17 18:26:47.219765 (UTC) Camera SITENAME-1.camera.CAMERANAME-1 has been closed after being in use for 175 seconds in automatic mode

2014-06-18 14:48:30.241732 (UTC) Camera SITENAME-2.camera.CAMERANAME-2 has been closed after being in use for 281 seconds in manual mode

2014-06-18 15:52:53.974993 (UTC) Camera SITENAME-3.camera.CAMERANAME-3 has been closed after being in use for 5494 seconds in Unknown mode

2014-06-18 15:53:10.312491 (UTC) Camera SITENAME-4.camera.CAMERANAME-4 has been closed after being in use for 5511 seconds in watching mode

How can a do a search, to report the total usage time, for each camera, at each site, in each mode?

and.. print pretty charts and plots?
thanks!

Fred.Ziegler@alum.mit.edu

Tags (2)
0 Karma

jeremiahc4
Builder

You could either use the field extractor UI to try and solve it, or you could use rex on the search line to handle the same.

Something like (untested, but probably close);

your base search | rex "Camera (?P<CameraSite>.+) has been closed after being in use for (?P<UsageTime>\d*) seconds" | chart sum(UsageTime) by CameraSite
0 Karma

jeremiahc4
Builder

You probably need to modify the regex ".+" in the CameraSite field to capture the full name... I usually have to play around with it, but could either be something like

(?P[\w\d\-\.]*) or (?P.*[^ ])

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...