Splunk Search

how to convert days,minutes,hours and seconds to just seconds format to obtain the visualization?

pavanae
Builder

I have a simple lookup query as follows :-

| inputlookup ABC.csv

which gives the result as follows :-

alt text

Which doesn't give me any visualization. Now how can I get a "Line Chart" visualization with 3 line patterns like "time-to-close", "time-to-discover" and "time-to-respond"

I assume the current time format for all the 3 columns should be converted to a unique value either by seconds or by minutes inorder to get any visualization like "1 d,0 h, 0 m and 0 s" as "86400s" but I'm not sure how to get the eval logic for that.

Any help would be great.

0 Karma
1 Solution

renjith_nair
Legend

Try this and if it works for you, then convert all fields similar to this

    |stats count|eval time_to_close="1 d,0 h, 0 m and 1 s"|eval time_to_close=split(replace(replace(time_to_close," ",":"),",",":"),":")
    |eval time_to_close_sec=tonumber(mvindex(time_to_close,0))*86400+tonumber(mvindex(time_to_close,2))*3600+tonumber(mvindex(time_to_close,5))*60+tonumber(mvindex(time_to_close,8))
Happy Splunking!

View solution in original post

0 Karma

poete
Builder

Hi,

what about this?

|  makeresults |  eval Parameter="321 d, 10 h, 48 m and 46 s" |eval ts=strptime(Parameter,"%j d, %H h, %M m and %S s")

ts is what you need

0 Karma

pavanae
Builder

@poete I have more than 40 rows. The above solution gives me the solution for just row 1 . Here I want to use the lookup table results (40 rows) and then convert them in a new row. Is there any possibility to get the required result.

0 Karma

renjith_nair
Legend

Try this and if it works for you, then convert all fields similar to this

    |stats count|eval time_to_close="1 d,0 h, 0 m and 1 s"|eval time_to_close=split(replace(replace(time_to_close," ",":"),",",":"),":")
    |eval time_to_close_sec=tonumber(mvindex(time_to_close,0))*86400+tonumber(mvindex(time_to_close,2))*3600+tonumber(mvindex(time_to_close,5))*60+tonumber(mvindex(time_to_close,8))
Happy Splunking!
0 Karma

pavanae
Builder

@renjith.nair I have more than 40 rows. The above solution gives me the solution for just row "1 d,0 h, 0 m and 1 s" . Here I want to use the lookup table results (40 rows) and then convert them in a new row. Is there any possibility to get the required result.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...