<?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: How do I extract a string of numbers using Rex to work the AVG out from a string to a number in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510210#M142771</link>
    <description>&lt;LI-CODE lang="markup"&gt;| makeresults count=20
| eval _raw="sample: ".printf("%02d",random() % 24).":".printf("%02d",random() % 60).":".printf("%02d",random() % 60).".".printf("%07d",random() % 9999999)
| rename COMMENT as "this is sample"
| rename COMMNET as "rex extracts two fields"
| rex "(?&amp;lt;times&amp;gt;\d{2}:\d{2}:\d{2})\.(?&amp;lt;sec&amp;gt;\d{7})"
| convert dur2sec(times)
| eval sec="0.".sec
| eval seconds=times+sec
| eventstats avg(seconds)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;convert&amp;nbsp;&lt;/STRONG&gt;is useful.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jul 2020 11:59:40 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-07-21T11:59:40Z</dc:date>
    <item>
      <title>How do I extract a string of numbers using Rex to work the AVG out from a string to a number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510197#M142765</link>
      <description>&lt;P&gt;How do I extract a string of numbers using Rex to work the AVG out from a string to a number As it is showing as blank. The number format 00:00:00.0000000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks Joe&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 10:00:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510197#M142765</guid>
      <dc:creator>joe06031990</dc:creator>
      <dc:date>2020-07-21T10:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a string of numbers using Rex to work the AVG out from a string to a number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510210#M142771</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults count=20
| eval _raw="sample: ".printf("%02d",random() % 24).":".printf("%02d",random() % 60).":".printf("%02d",random() % 60).".".printf("%07d",random() % 9999999)
| rename COMMENT as "this is sample"
| rename COMMNET as "rex extracts two fields"
| rex "(?&amp;lt;times&amp;gt;\d{2}:\d{2}:\d{2})\.(?&amp;lt;sec&amp;gt;\d{7})"
| convert dur2sec(times)
| eval sec="0.".sec
| eval seconds=times+sec
| eventstats avg(seconds)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;convert&amp;nbsp;&lt;/STRONG&gt;is useful.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 11:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510210#M142771</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-21T11:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a string of numbers using Rex to work the AVG out from a string to a number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510211#M142772</link>
      <description>&lt;P class="lia-align-justify"&gt;Hi&lt;/P&gt;&lt;P class="lia-align-justify"&gt;as we discussed on&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Issue-with-the-AVG-however-min-and-max-work-fine/td-p/510077/jump-to/first-unread-message" target="_blank"&gt;&amp;nbsp;Issue with the AVG however min and max work fine.&amp;nbsp;&lt;/A&gt;&amp;nbsp;this is probably on part of date + time field not pure string? Are you interested only for hour, min, sec, fraction part or full timestamp?&lt;/P&gt;&lt;P class="lia-align-justify"&gt;Here is how you could convert this time to epoch:&lt;/P&gt;&lt;LI-CODE lang="java"&gt;| makeresults
| eval foo = "00:00:00.0000000"
| eval bar = strptime (foo, "%H:%M:%S.%7Q")
| eval foobar = strftime (bar, "%H:%M:%S.%7Q")
| table foo bar foobar&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 21 Jul 2020 12:03:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510211#M142772</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-21T12:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a string of numbers using Rex to work the AVG out from a string to a number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510227#M142780</link>
      <description>&lt;P&gt;Hi, I just need to pull the AVG from the string field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 13:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510227#M142780</guid>
      <dc:creator>joe06031990</dc:creator>
      <dc:date>2020-07-21T13:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a string of numbers using Rex to work the AVG out from a string to a number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510231#M142782</link>
      <description>&lt;P&gt;You cannot calculate AVG from string field. Avg function is available only for numeric fields.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.5/SearchReference/Aggregatefunctions" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.5/SearchReference/Aggregatefunctions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are more what and when you could use AVG and other aggregate functions.&lt;/P&gt;&lt;P&gt;Of course if string field's contains numeric values you could first transform string to numeric and then use AVG e.g. with stats to get the average.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 13:12:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510231#M142782</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-21T13:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a string of numbers using Rex to work the AVG out from a string to a number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510232#M142783</link>
      <description>&lt;P&gt;Hi, I did try Convert to Convert the string into Numeric but got the same issue.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 13:16:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-string-of-numbers-using-Rex-to-work-the-AVG/m-p/510232#M142783</guid>
      <dc:creator>joe06031990</dc:creator>
      <dc:date>2020-07-21T13:16:10Z</dc:date>
    </item>
  </channel>
</rss>

