<?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 split field into multiple fields for comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445857#M126495</link>
    <description>&lt;P&gt;Excellent feedback! I appreciate you working with me to figure this out. I think we've arrived at the root of the problem.&lt;/P&gt;

&lt;P&gt;I mistakenly assumed the data we were trying to extract was in the joined dataset, but it appears that it's actually coming from the main search!&lt;/P&gt;

&lt;P&gt;The "n" fields is created in the first eval pipe, where the &lt;CODE&gt;_raw&lt;/CODE&gt; is split on commas. This "n" field has all of the data we're looking for -- just in multi-value format. &lt;/P&gt;

&lt;P&gt;In order to index these multi-value fields so we can work with them, we use the &lt;CODE&gt;mvindex&lt;/CODE&gt;. You can see in your base search you have two of these values indexed already -- Name and OS. In order to add the time field to the results, we'll need to &lt;CODE&gt;mvindex&lt;/CODE&gt; that field as well.&lt;/P&gt;

&lt;P&gt;First, try this for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index=os sourcetype=chef:csv host="vxkip-v87k6btx" AND source=/home/hab/node_status.csv
| eval n=split(_raw,",")
| eval Time_Field=mvindex(n, 0)
| eval Name=mvindex(n, 1)
| eval OS=mvindex(n, 2)
| search OS = "windows"
| search OS != "ubuntu"
| where len(Name) &amp;gt; 2
| eval Name=lower(Name) 
| eval Name = trim(replace(Name,".lm.lmig.com.","")) 
| replace ".lm.lmig.com" WITH "" IN Name 
| eval Name = trim(replace(Name,".kc.lmig.com",""))
| eval Name = trim(replace(Name,".lmx.lmig.com",""))
| eval Name = trim(replace(Name,".lmxt.lmig.com",""))
| eval Name = trim(replace(Name,".lmig.com",""))
| eval Name = trim(replace(Name,".lm",""))
| eval Name = trim(replace(Name,".dsm.pin.safeco.com",""))
| table Time_Field Name OS 
| sort Name
| rename Name as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you've confirmed that your three fields are there, go ahead and add the join statement, and everything should show up as expected.&lt;/P&gt;

&lt;P&gt;As a bonus in the case that you're interested, you could use the rex command to accomplish the same thing (in place of the split/mvindex method) like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index=os sourcetype=chef:csv host="vxkip-v87k6btx" AND source=/home/hab/node_status.csv
 | rex field=_raw "(?&amp;lt;Time_Field&amp;gt;\d+\s(?:seconds?|minutes?|hours?|days?)\sago)\,\s(?&amp;lt;Name&amp;gt;[^\,]+)\,\s(?&amp;lt;OS&amp;gt;[^\n]+)\." 
| search OS = "windows"
| search OS != "ubuntu"
| where len(Name) &amp;gt; 2
| eval Name=lower(Name) 
| eval Name = trim(replace(Name,".lm.lmig.com.","")) 
| replace ".lm.lmig.com" WITH "" IN Name 
| eval Name = trim(replace(Name,".kc.lmig.com",""))
| eval Name = trim(replace(Name,".lmx.lmig.com",""))
| eval Name = trim(replace(Name,".lmxt.lmig.com",""))
| eval Name = trim(replace(Name,".lmig.com",""))
| eval Name = trim(replace(Name,".lm",""))
| eval Name = trim(replace(Name,".dsm.pin.safeco.com",""))
| table Time_Field Name OS 
| sort Name
| rename Name as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You also have much more flexibility with regular expressions, but both ways &lt;EM&gt;should&lt;/EM&gt; work for this scenario.&lt;/P&gt;

&lt;P&gt;I apologize for misunderstanding the question, I hope this is the solution that ends up working for you!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2019 23:13:49 GMT</pubDate>
    <dc:creator>rbechtold</dc:creator>
    <dc:date>2019-08-14T23:13:49Z</dc:date>
    <item>
      <title>How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445849#M126487</link>
      <description>&lt;P&gt;Hello, need help from the experts.&lt;/P&gt;

&lt;P&gt;My search results (_raw) is this:&lt;BR /&gt;
    &lt;STRONG&gt;Event&lt;BR /&gt;
1 minute  ago, vmrit-c4ca0001.lm.lmig.com, windows 6.3.9600.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I would like to split this into 3 different fields so I can do some comparison.  Something like:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Field1                             Field2                                       Field3&lt;BR /&gt;
1 minute ago       vmrit-c4ca001.lm.lmig.com         windows 6.3.9600.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Appreciate any help you can give to this newbie!&lt;BR /&gt;&lt;BR /&gt;
Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 19:38:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445849#M126487</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2019-08-13T19:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445850#M126488</link>
      <description>&lt;P&gt;Hey Owie,&lt;/P&gt;

&lt;P&gt;This can easily be accomplished using regular expression to extract the fields from your data (using the &lt;CODE&gt;rex&lt;/CODE&gt; command)!&lt;/P&gt;

&lt;P&gt;Try adding this to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...Base Search...
| rex field=_raw "(?&amp;lt;Field1&amp;gt;[^\,]+)\,(?&amp;lt;Field2&amp;gt;[^\,]+)\,(?&amp;lt;Field3&amp;gt;.*)\."
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should work based on the example data you provided, however if you run into any trouble or it doesn't work let me know and I can help you write a more precise extraction.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Rex command documentation:&lt;/STRONG&gt; &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Rex"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Rex&lt;/A&gt;&lt;BR /&gt;
Also, if you're interested in learning regex, I recommend checking out this site: &lt;A href="https://regexone.com/"&gt;https://regexone.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I hope this helps!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 20:05:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445850#M126488</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-08-13T20:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445851#M126489</link>
      <description>&lt;P&gt;thanks rbechtold!  i will go ahead and try this one.  will also check out the site you recommended.  &lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 20:21:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445851#M126489</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2019-08-13T20:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445852#M126490</link>
      <description>&lt;P&gt;hi there, didn't yield any results for me.  &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 20:28:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445852#M126490</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2019-08-13T20:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445853#M126491</link>
      <description>&lt;P&gt;That is strange!&lt;/P&gt;

&lt;P&gt;I'm trying to think of why this wouldn't work. Would you mind sharing your base search with me? I'm wondering if we got rid of the &lt;CODE&gt;_raw&lt;/CODE&gt; field somewhere in the search. &lt;/P&gt;

&lt;P&gt;Here is a search showing how the extraction should have worked on the data you provided (copy and paste this into Splunk):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults count=1
| eval _raw = "1 minute ago, vmrit-c4ca0001.lm.lmig.com, windows 6.3.9600."
| rex field=_raw "(?&amp;lt;Field1&amp;gt;[^\,]+)\,(?&amp;lt;Field2&amp;gt;[^\,]+)\,(?&amp;lt;Field3&amp;gt;.*)\."
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Aug 2019 20:53:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445853#M126491</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-08-13T20:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445854#M126492</link>
      <description>&lt;P&gt;hi rbechtold here's the base search:&lt;/P&gt;

&lt;P&gt;| search index=os sourcetype=chef:csv host="vxkip-v87k6btx" AND source=/home/hab/node_status.csv&lt;BR /&gt;
| eval n=split(_raw,",")&lt;BR /&gt;
| eval Name=mvindex(n, 1)&lt;BR /&gt;
| eval OS=mvindex(n, 2)&lt;BR /&gt;
| search OS = "&lt;EM&gt;windows&lt;/EM&gt;"&lt;BR /&gt;
| search OS != "ubuntu"&lt;BR /&gt;
| where len(Name) &amp;gt; 2&lt;BR /&gt;
| eval Name=lower(Name) &lt;BR /&gt;
| eval Name = trim(replace(Name,".lm.lmig.com.","")) &lt;BR /&gt;
| replace ".lm.lmig.com" WITH "" IN Name &lt;BR /&gt;
| eval Name = trim(replace(Name,".kc.lmig.com",""))&lt;BR /&gt;
| eval Name = trim(replace(Name,".lmx.lmig.com",""))&lt;BR /&gt;
| eval Name = trim(replace(Name,".lmxt.lmig.com",""))&lt;BR /&gt;
| eval Name = trim(replace(Name,".lmig.com",""))&lt;BR /&gt;
| eval Name = trim(replace(Name,".lm",""))&lt;BR /&gt;
| eval Name = trim(replace(Name,".dsm.pin.safeco.com",""))&lt;BR /&gt;
| table Name OS &lt;BR /&gt;
| sort Name&lt;BR /&gt;
| rename Name as host&lt;BR /&gt;
|join type=left host&lt;BR /&gt;
   [search index=wineventlog* sourcetype=WinEventLog:Application SourceName=Chef &lt;BR /&gt;
   | stats values(&lt;EM&gt;) as * by host&lt;BR /&gt;
   | rex field=host "(?[^.]+)." &lt;BR /&gt;
   | rex field=_raw "(?[^\,]+)\,(?[^\,]+)\,(?.&lt;/EM&gt;)."&lt;BR /&gt;&lt;BR /&gt;
   | eval host = lower(host)]&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:43:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445854#M126492</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2020-09-30T01:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445855#M126493</link>
      <description>&lt;P&gt;Ahh, that makes more sense!&lt;/P&gt;

&lt;P&gt;We're losing the &lt;CODE&gt;_raw&lt;/CODE&gt; field  with this line:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
|stats values(*) AS * by host
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just as a heads up, I've slightly modified the regex to make it more specific to your dataset.&lt;BR /&gt;
I have two possible solutions for you --&lt;/P&gt;

&lt;P&gt;The first is to put the extraction before the stats command to make sure we have the &lt;CODE&gt;_raw&lt;/CODE&gt; field available for extracting like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...BASE SEARCH...
|join type=left host
[search index=wineventlog* sourcetype=WinEventLog:Application SourceName=Chef 
| rex field=_raw "(?&amp;lt;Field1&amp;gt;\d+\s(?:seconds?|minutes?|hours?|days?)\sago)\,\s(?&amp;lt;Field2&amp;gt;[^\,]+)\,\s(?&amp;lt;Field3&amp;gt;[^\n]+)\."
| stats values(*) as * by host
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second solution would be to check to see what fields we're actually working with after we run the stats command.&lt;/P&gt;

&lt;P&gt;I would need you to run this for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wineventlog* sourcetype=WinEventLog:Application SourceName=Chef 
| stats values() as by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and then tell me what the field name is that contains the logs that look like this:&lt;BR /&gt;
&lt;STRONG&gt;1 minute ago, vmrit-c4ca0001.lm.lmig.com, windows 6.3.9600.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;It's possible we should be extracting from a field other than &lt;CODE&gt;_raw&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Let me know how it goes!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 18:49:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445855#M126493</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-08-14T18:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445856#M126494</link>
      <description>&lt;P&gt;hi i ran this:&lt;BR /&gt;
index=wineventlog* sourcetype=WinEventLog:Application SourceName=Chef &lt;BR /&gt;
   | stats values() by host&lt;/P&gt;

&lt;P&gt;search results:&lt;BR /&gt;
in the statistics tab and events tab there's no field that actually shows what we're looking for. &lt;/P&gt;

&lt;P&gt;but if i include the base search coming from the csv file, &lt;BR /&gt;
search results:&lt;BR /&gt;
statistics tab does not show any field that includes the log that we're looking for. &lt;BR /&gt;
in the events tab, _raw format shows the log as the first line.  and when i expand a specific event, field "n" has all these information&lt;/P&gt;

&lt;P&gt;n&lt;BR /&gt;
0 minutes ago&lt;BR /&gt;&lt;BR /&gt;
vmpit-hctxdb01.lm.lmig.com&lt;BR /&gt;&lt;BR /&gt;
windows 6.3.9600&lt;/P&gt;

&lt;P&gt;thank you so much for the help!&lt;BR /&gt;&lt;BR /&gt;
i thought this was going to be an easy search and chart.  &lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 21:51:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445856#M126494</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2019-08-14T21:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445857#M126495</link>
      <description>&lt;P&gt;Excellent feedback! I appreciate you working with me to figure this out. I think we've arrived at the root of the problem.&lt;/P&gt;

&lt;P&gt;I mistakenly assumed the data we were trying to extract was in the joined dataset, but it appears that it's actually coming from the main search!&lt;/P&gt;

&lt;P&gt;The "n" fields is created in the first eval pipe, where the &lt;CODE&gt;_raw&lt;/CODE&gt; is split on commas. This "n" field has all of the data we're looking for -- just in multi-value format. &lt;/P&gt;

&lt;P&gt;In order to index these multi-value fields so we can work with them, we use the &lt;CODE&gt;mvindex&lt;/CODE&gt;. You can see in your base search you have two of these values indexed already -- Name and OS. In order to add the time field to the results, we'll need to &lt;CODE&gt;mvindex&lt;/CODE&gt; that field as well.&lt;/P&gt;

&lt;P&gt;First, try this for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index=os sourcetype=chef:csv host="vxkip-v87k6btx" AND source=/home/hab/node_status.csv
| eval n=split(_raw,",")
| eval Time_Field=mvindex(n, 0)
| eval Name=mvindex(n, 1)
| eval OS=mvindex(n, 2)
| search OS = "windows"
| search OS != "ubuntu"
| where len(Name) &amp;gt; 2
| eval Name=lower(Name) 
| eval Name = trim(replace(Name,".lm.lmig.com.","")) 
| replace ".lm.lmig.com" WITH "" IN Name 
| eval Name = trim(replace(Name,".kc.lmig.com",""))
| eval Name = trim(replace(Name,".lmx.lmig.com",""))
| eval Name = trim(replace(Name,".lmxt.lmig.com",""))
| eval Name = trim(replace(Name,".lmig.com",""))
| eval Name = trim(replace(Name,".lm",""))
| eval Name = trim(replace(Name,".dsm.pin.safeco.com",""))
| table Time_Field Name OS 
| sort Name
| rename Name as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you've confirmed that your three fields are there, go ahead and add the join statement, and everything should show up as expected.&lt;/P&gt;

&lt;P&gt;As a bonus in the case that you're interested, you could use the rex command to accomplish the same thing (in place of the split/mvindex method) like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index=os sourcetype=chef:csv host="vxkip-v87k6btx" AND source=/home/hab/node_status.csv
 | rex field=_raw "(?&amp;lt;Time_Field&amp;gt;\d+\s(?:seconds?|minutes?|hours?|days?)\sago)\,\s(?&amp;lt;Name&amp;gt;[^\,]+)\,\s(?&amp;lt;OS&amp;gt;[^\n]+)\." 
| search OS = "windows"
| search OS != "ubuntu"
| where len(Name) &amp;gt; 2
| eval Name=lower(Name) 
| eval Name = trim(replace(Name,".lm.lmig.com.","")) 
| replace ".lm.lmig.com" WITH "" IN Name 
| eval Name = trim(replace(Name,".kc.lmig.com",""))
| eval Name = trim(replace(Name,".lmx.lmig.com",""))
| eval Name = trim(replace(Name,".lmxt.lmig.com",""))
| eval Name = trim(replace(Name,".lmig.com",""))
| eval Name = trim(replace(Name,".lm",""))
| eval Name = trim(replace(Name,".dsm.pin.safeco.com",""))
| table Time_Field Name OS 
| sort Name
| rename Name as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You also have much more flexibility with regular expressions, but both ways &lt;EM&gt;should&lt;/EM&gt; work for this scenario.&lt;/P&gt;

&lt;P&gt;I apologize for misunderstanding the question, I hope this is the solution that ends up working for you!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 23:13:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445857#M126495</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-08-14T23:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445858#M126496</link>
      <description>&lt;P&gt;i got the Time_Field showing now!  thank you!  &lt;/P&gt;

&lt;P&gt;looks i have to strip the Time_Field to only get the number and then do a comparison &lt;/P&gt;

&lt;P&gt;you're great!  might have to ask you one more thing.  i will run my search and will let you know! &lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 17:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445858#M126496</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2019-08-15T17:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445859#M126497</link>
      <description>&lt;P&gt;here's what the Time_Field looks like.&lt;BR /&gt;&lt;BR /&gt;
Time_Field&lt;BR /&gt;
0 minutes ago&lt;/P&gt;

&lt;P&gt;now i have to take '0' and compare if &amp;gt;4 then Process_Down&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:45:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445859#M126497</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2020-09-30T01:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445860#M126498</link>
      <description>&lt;P&gt;Perfect! I'm glad to hear everything is working as expected. &lt;/P&gt;

&lt;P&gt;In order to convert the string "x minutes ago" into an integer we can work with, we can use a combination of &lt;CODE&gt;rex&lt;/CODE&gt; to extract the data we need from the Time_Field,  and &lt;CODE&gt;eval&lt;/CODE&gt; to create a new "Converted_Minutes" field based on those values. &lt;/P&gt;

&lt;P&gt;We'll then use another &lt;CODE&gt;eval&lt;/CODE&gt; statement to create a "Status" field that decides if the process is up or down based on the output of the Converted_Minutes field.&lt;/P&gt;

&lt;P&gt;Go ahead and change your base search to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search index=os sourcetype=chef:csv host="vxkip-v87k6btx" AND source=/home/hab/node_status.csv 
| eval n=split(_raw,",") 
| eval Time_Field=mvindex(n, 0) 
| eval Name=mvindex(n, 1) 
| eval OS=mvindex(n, 2) 
| search OS = "windows" 
| search OS != "ubuntu" 
| where len(Name) &amp;gt; 2 
| eval Name=lower(Name) 
| eval Name = trim(replace(Name,".lm.lmig.com.","")) 
| replace ".lm.lmig.com" WITH "" IN Name 
| eval Name = trim(replace(Name,".kc.lmig.com","")) 
| eval Name = trim(replace(Name,".lmx.lmig.com","")) 
| eval Name = trim(replace(Name,".lmxt.lmig.com","")) 
| eval Name = trim(replace(Name,".lmig.com","")) 
| eval Name = trim(replace(Name,".lm","")) 
| eval Name = trim(replace(Name,".dsm.pin.safeco.com","")) 
| rex field=Time_Field "(?&amp;lt;digit&amp;gt;\d+)\s(?&amp;lt;time_unit&amp;gt;second|minute|hour|day)s?" 
| eval Converted_Minutes = if(time_unit = "second", round(digit / 60,0), if(time_unit = "minute", digit, if(time_unit = "hour", digit * 60, if(time_unit = "day", digit * 1440, "Time Length not Accounted For")))) 
| eval Status = if(Converted_Minutes &amp;gt; 4, "Process_Down", "Process_Up") 
| table Time_Field Converted_Minutes Status Name OS
| sort Name 
| rename Name as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The Converted_Minutes field will translate any time from the Time_Field (Seconds, Minutes, Hours, Days) into minutes. You can use this field for visualizations and comparisons since it will always output as an integer. &lt;/P&gt;

&lt;P&gt;You should be able to add your join after you confirm the "Converted_Minutes" field and the "Status" field are showing up properly!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:46:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445860#M126498</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2020-09-30T01:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to split field into multiple fields for comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445861#M126499</link>
      <description>&lt;P&gt;YOU ARE AWESOME!  this is working perfectly now!  thank you so much for all the help and patience!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:10:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-split-field-into-multiple-fields-for-comparison/m-p/445861#M126499</guid>
      <dc:creator>owie6466</dc:creator>
      <dc:date>2019-08-15T19:10:39Z</dc:date>
    </item>
  </channel>
</rss>

