<?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 to extract the time and place in buckets? in Deployment Architecture</title>
    <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-the-time-and-place-in-buckets/m-p/98188#M3634</link>
    <description>&lt;P&gt;I don't know what you mean by "until breached" or "already breached." Exactly what are you comparing the nextBreachTime to?&lt;BR /&gt;&lt;BR /&gt;
However, this rex command will extract the field for you and translate it into epoch time, so that you can do time arithmetic.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| rex "\&amp;lt;nextBreachTime\&amp;gt;(?&amp;lt;nextBreachTime&amp;gt;\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2})\&amp;lt;/nextBreachTime\&amp;gt;"
| eval nextBreachTime=strptime(nextBreachTime,"%m/%d/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to extract a large number of fields from xml-formatted input, take a look at the &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.4/SearchReference/Xmlkv"&gt;xmlkv&lt;/A&gt; command or the &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.4/SearchReference/Spath"&gt;spath&lt;/A&gt; command.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2012 04:17:46 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-10-23T04:17:46Z</dc:date>
    <item>
      <title>How to extract the time and place in buckets?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-the-time-and-place-in-buckets/m-p/98187#M3633</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I am trying to calculate the data on the basis of "next.breachtime" field in data. I need to create 4 fields with fields which have already been breached,0-4 hours till breached,4-8 hours till breached,greater than 8 hours. I understand the concept of using eval statements and case statements to get it done. I am getting stuck in the concept of extracting the data from that field a computing it into the buckets.  &lt;/P&gt;

&lt;P&gt;This is hoe that field will be in the data. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nextBreachTime&amp;gt;10/25/2012 13:17:52&amp;lt;/nextBreachTime&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what I am trying to use. Can anyone please tell me on how do I extract that data and place it in the case statements. I am thinking of using rex statements, but I am kinda new to that so finding it a bit difficult to understand how to write rex statements&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval mybucket=case(record.nextBreachTime=0,1,record.nextBreachTime&amp;lt;4,2,record.nextBreachTime&amp;lt;8,3,record.nextBreachTime&amp;gt;8,4)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards&lt;/P&gt;

&lt;P&gt;theou&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2012 15:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-the-time-and-place-in-buckets/m-p/98187#M3633</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2012-10-22T15:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the time and place in buckets?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-the-time-and-place-in-buckets/m-p/98188#M3634</link>
      <description>&lt;P&gt;I don't know what you mean by "until breached" or "already breached." Exactly what are you comparing the nextBreachTime to?&lt;BR /&gt;&lt;BR /&gt;
However, this rex command will extract the field for you and translate it into epoch time, so that you can do time arithmetic.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| rex "\&amp;lt;nextBreachTime\&amp;gt;(?&amp;lt;nextBreachTime&amp;gt;\d{2}/\d{2}/\d{4} \d{2}:\d{2}:\d{2})\&amp;lt;/nextBreachTime\&amp;gt;"
| eval nextBreachTime=strptime(nextBreachTime,"%m/%d/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to extract a large number of fields from xml-formatted input, take a look at the &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.4/SearchReference/Xmlkv"&gt;xmlkv&lt;/A&gt; command or the &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.4/SearchReference/Spath"&gt;spath&lt;/A&gt; command.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 04:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-the-time-and-place-in-buckets/m-p/98188#M3634</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-10-23T04:17:46Z</dc:date>
    </item>
  </channel>
</rss>

