<?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: Convert string to number and compare in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321417#M96008</link>
    <description>&lt;P&gt;Just noticed, without &lt;CODE&gt;delim&lt;/CODE&gt; also &lt;CODE&gt;makemv&lt;/CODE&gt; command works.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2017 09:39:50 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-10-23T09:39:50Z</dc:date>
    <item>
      <title>Convert string to number and compare</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321414#M96005</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
why this is not working ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval WithUnit="0/1 2/2 3/8 0/0 5/5" | makemv WithUnit | table WithUnit | mvexpand WithUnit | rex field=WithUnit "(?&amp;lt;ReplicasA&amp;gt;\d+)\/(?&amp;lt;ReplicasB&amp;gt;\d+)" | where ReplicasA &amp;gt; 0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I even tryied this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval WithUnit="0/1 2/2 3/8 0/0 5/5" | makemv WithUnit | table WithUnit | mvexpand WithUnit | rex field=WithUnit "(?&amp;lt;ReplicasA&amp;gt;\d+)\/(?&amp;lt;ReplicasB&amp;gt;\d+)"| eval n=tonumber(ReplicasA) | where n &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 08:58:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321414#M96005</guid>
      <dc:creator>Rialf1959</dc:creator>
      <dc:date>2017-10-23T08:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to number and compare</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321415#M96006</link>
      <description>&lt;P&gt;above works for me though. I can see the result is filtered to 3 rows which has n&amp;gt; 0&lt;BR /&gt;
Which Splunk version you using?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval WithUnit="0/1 2/2 3/8 0/0 5/5" | makemv WithUnit | table WithUnit | mvexpand WithUnit | rex field=WithUnit "(?&amp;lt;ReplicasA&amp;gt;\d+)\/(?&amp;lt;ReplicasB&amp;gt;\d+)"| where ReplicasA &amp;lt; ReplicasB
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Oct 2017 09:30:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321415#M96006</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-10-23T09:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to number and compare</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321416#M96007</link>
      <description>&lt;P&gt;[Updated Answer based on Sample JSON Data]&lt;/P&gt;

&lt;P&gt;@Rialf1959, is this a single event or can an event have multiple such nodes? I am trying to understand as to why you were trying to use multivalue field evaluations?&lt;/P&gt;

&lt;P&gt;I can see &lt;CODE&gt;"Replicas":"1/1"&lt;/CODE&gt; in the data is what you might be interested in. If your fields are extracted, your field &lt;CODE&gt;Replicas&lt;/CODE&gt; should have value &lt;CODE&gt;1/1&lt;/CODE&gt; extracted by default. All you would need to do is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
 | eval Replicas=split(Replicas,"/")
 | eval ReplicasA=mvindex(Replicas,0)
 | eval ReplicasB=mvindex(Replicas,1)
 | where ReplicasA &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search based on your sample data provided herewith to illustrate above code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  makeresults
|  eval _raw ="{\"ID\":\"de7zc794qqk1\",\"Image\":\"example.com/test:1.0.1\",\"Mode\":\"replicated\",\"Name\":\"test\",\"Ports\":\"\",\"Replicas\":\"1/1\"}"
|  spath
|  table Replicas
|  eval Replicas=split(Replicas,"/")
|  eval ReplicasA=mvindex(Replicas,0)
|  eval ReplicasB=mvindex(Replicas,1)
|  where ReplicasA &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;@Rialf1959, try the following (I have tried with space as delimiter for &lt;CODE&gt;makemv&lt;/CODE&gt; command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval WithUnit="0/1 2/2 3/8 0/0 5/5"
| makemv WithUnit delim=" "
| mvexpand WithUnit 
| rex field=WithUnit "(?&amp;lt;ReplicasA&amp;gt;\d+)\/(?&amp;lt;ReplicasB&amp;gt;\d+)" 
| where ReplicasA &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or use &lt;CODE&gt;split()&lt;/CODE&gt; with &lt;CODE&gt;mvindex&lt;/CODE&gt; instead of &lt;CODE&gt;rex&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval WithUnit="0/1 2/2 3/8 0/0 5/5"
| makemv WithUnit delim=" "
| mvexpand WithUnit 
| eval WithUnit=split(WithUnit ,"/")
| eval ReplicasA=mvindex(WithUnit,0)
| eval ReplicasB=mvindex(WithUnit,1)
| where ReplicasA &amp;gt; 0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Oct 2017 09:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321416#M96007</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-23T09:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to number and compare</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321417#M96008</link>
      <description>&lt;P&gt;Just noticed, without &lt;CODE&gt;delim&lt;/CODE&gt; also &lt;CODE&gt;makemv&lt;/CODE&gt; command works.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 09:39:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321417#M96008</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-23T09:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to number and compare</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321418#M96009</link>
      <description>&lt;P&gt;It does now work with my data.&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
{"ID":"de7zc794qqk1","Image":"example.com/test:1.0.1","Mode":"replicated","Name":"test","Ports":"","Replicas":"1/1"}&lt;/P&gt;

&lt;P&gt;P.S.: I have enabled json indexed extractions. So field are extracted.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 10:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321418#M96009</guid>
      <dc:creator>Rialf1959</dc:creator>
      <dc:date>2017-10-23T10:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert string to number and compare</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321419#M96010</link>
      <description>&lt;P&gt;@Rialf1959, I have updated my answer based on this sample data. However, it is confusing with this data as to why you had multi value field evaluation in your question when the information is already available in field &lt;CODE&gt;Replicas&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 16:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-string-to-number-and-compare/m-p/321419#M96010</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-23T16:26:54Z</dc:date>
    </item>
  </channel>
</rss>

