<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting Hours:Minutes'Seconds to a numerical value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29316#M5898</link>
    <description>&lt;P&gt;Isn't the answer to this question the &lt;EM&gt;same one&lt;/EM&gt; I gave you on your prior question?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/64153/greater-than-filter"&gt;http://splunk-base.splunk.com/answers/64153/greater-than-filter&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Nov 2012 18:00:51 GMT</pubDate>
    <dc:creator>sowings</dc:creator>
    <dc:date>2012-11-09T18:00:51Z</dc:date>
    <item>
      <title>Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29314#M5896</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;

&lt;P&gt;I have extracted a field within my data that I have called 'duration'. This field is from a call log and shows the duration of each call that took place. It is in the format of :-&lt;/P&gt;

&lt;P&gt;hours:minutes'seconds  -  for example :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;00:02'16
00:00'38
00:00'38
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to construct a way to calculate the total number of seconds contained within this field. Once done I can then easily comapare different records and plot graphs showing such things a spread of call durations and average call time, etc.  &lt;/P&gt;

&lt;P&gt;However, I am having trouble constructing such an expression.&lt;/P&gt;

&lt;P&gt;Any help would be greatly received.  -   Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2012 17:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29314#M5896</guid>
      <dc:creator>lanode</dc:creator>
      <dc:date>2012-11-09T17:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29315#M5897</link>
      <description>&lt;P&gt;This should be helpful for you. It converts to minutes but it's an easy change to make it seconds.  This uses rex to pull out hours, minutes and seconds which you could have permanently as field extractions.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/5120/convert-text-into-numbers-hhmmss-into-minutes"&gt;http://splunk-base.splunk.com/answers/5120/convert-text-into-numbers-hhmmss-into-minutes&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2012 17:55:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29315#M5897</guid>
      <dc:creator>sdaniels</dc:creator>
      <dc:date>2012-11-09T17:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29316#M5898</link>
      <description>&lt;P&gt;Isn't the answer to this question the &lt;EM&gt;same one&lt;/EM&gt; I gave you on your prior question?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/64153/greater-than-filter"&gt;http://splunk-base.splunk.com/answers/64153/greater-than-filter&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2012 18:00:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29316#M5898</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2012-11-09T18:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29317#M5899</link>
      <description>&lt;P&gt;Yes, of course you're absolutely right. In the post you refer to I came up with a half hearted solution where I just wanted to identify calls in excess of 1 minute. I did this by simply discounting everything where the minutes portion did not equal '00'.  Before posting this question I see I really should have referred back to your answers and studied them in greater depth.  I will be sure to do this now.  Part of my problem with this does not necessarily revolve around the math, but more so the command structure to evaluate the answer once the total number of minutes per call has been deduced&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2012 19:10:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29317#M5899</guid>
      <dc:creator>lanode</dc:creator>
      <dc:date>2012-11-09T19:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29318#M5900</link>
      <description>&lt;P&gt;The answer you refer to looks very interesting. I will read it in depth and see if I can transfer it to my problem. Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2012 20:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29318#M5900</guid>
      <dc:creator>lanode</dc:creator>
      <dc:date>2012-11-09T20:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29319#M5901</link>
      <description>&lt;P&gt;To handle the latter, once you've got the regex to extract the fields, doing the math gets you to a number of seconds. The _time field is also in seconds, so if a record comes in at the &lt;EM&gt;end&lt;/EM&gt; of a call, then you could subtract the discovered duration from the _time field to end up with the start time of the call, as well.&lt;/P&gt;

&lt;P&gt;Typically search commands flow from left to right, and pipes separate commands from one another. An &lt;CODE&gt;eval&lt;/CODE&gt; command adds fields to events. If you needed to filter by total duration, that's a simple &lt;CODE&gt;| search&lt;/CODE&gt; after the eval.&lt;/P&gt;

&lt;P&gt;Happy Splunking!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2012 20:18:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29319#M5901</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2012-11-09T20:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Hours:Minutes'Seconds to a numerical value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29320#M5902</link>
      <description>&lt;P&gt;Once again thank you to the 2 posters above.  Their suggestions helped me formulate a solution. &lt;/P&gt;

&lt;P&gt;And here it is for completeness :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search="foobar"
| rex field="duration" "(?&amp;lt;hour&amp;gt;\d{2}):(?&amp;lt;min&amp;gt;\d{2})'(?&amp;lt;sec&amp;gt;\d{2})"
| eval duration_seconds = ((hour*3600)+(min*60)+sec)
| rangemap field=duration_seconds "0-1min"=1-59 "1-3mins"=60-179 "3-8mins"=180-479 "8-15mins"=480-899 "15mins+"=900-36000
| stats count by range
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It allows me to extract the total call duration in seconds from a field formated as HH:MM'SS.&lt;/P&gt;

&lt;P&gt;The 'rangemap' function then provides a means to classify value ranges.&lt;/P&gt;

&lt;P&gt;Then finally the 'stats' command enables me to plot these values with respect to range on a chart.&lt;/P&gt;

&lt;P&gt;Great !!  -  Thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2012 12:36:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-Hours-Minutes-Seconds-to-a-numerical-value/m-p/29320#M5902</guid>
      <dc:creator>lanode</dc:creator>
      <dc:date>2012-11-12T12:36:14Z</dc:date>
    </item>
  </channel>
</rss>

