<?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 set a Variable from an Eval match? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317144#M94878</link>
    <description>&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval clientip="10.1.3.4" | eval isImportant=if(((cidrmatch("10.1.1.0/24", clientip)) OR (cidrmatch("10.1.2.0/24", clientip))), "true", "false")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Works with 10.1.1.4 and 10.1.2.4 properly, so you can try that.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2017 16:21:57 GMT</pubDate>
    <dc:creator>cpetterborg</dc:creator>
    <dc:date>2017-07-19T16:21:57Z</dc:date>
    <item>
      <title>How to set a Variable from an Eval match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317143#M94877</link>
      <description>&lt;P&gt;I am trying to set a new variable for each event, by using the eval command. Maybe I should a different command?&lt;/P&gt;

&lt;P&gt;I want to set a variable, isImportant, by IP address. I am trying to see if it falls into two or more ranges (10.1.1.* or 10.1.2.*). If the IP is in one of those ranges, I would like to have the variable isImportant set to true, otherwise set to false. &lt;/P&gt;

&lt;P&gt;I saw the following page:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Eval"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And it has an example for using one cidr range to set isLocal. I imagine I can use the example of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval isImportant=if(cidrmatch("10.1.1.0/24", clientip), "true", "false")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;for one range. When I try to use two ranges, it does not work. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval isImportant=if((cidrmatch("10.1.1.0/24", clientip)) OR (cidrmatch("10.1.2.0/24", clientip)))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second example does not work.&lt;/P&gt;

&lt;P&gt;Is there a way to combine conditions into the eval?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317143#M94877</guid>
      <dc:creator>stakor</dc:creator>
      <dc:date>2017-07-19T16:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a Variable from an Eval match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317144#M94878</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval clientip="10.1.3.4" | eval isImportant=if(((cidrmatch("10.1.1.0/24", clientip)) OR (cidrmatch("10.1.2.0/24", clientip))), "true", "false")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Works with 10.1.1.4 and 10.1.2.4 properly, so you can try that.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:21:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317144#M94878</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-07-19T16:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a Variable from an Eval match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317145#M94879</link>
      <description>&lt;P&gt;Have you tried &lt;CODE&gt;| eval isImportant=if((cidrmatch("10.1.1.0/24", clientip)) OR (cidrmatch("10.1.2.0/24", clientip)), "true", "false")&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:24:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317145#M94879</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-07-19T16:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a Variable from an Eval match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317146#M94880</link>
      <description>&lt;P&gt;You just specified the condition in if condition but no if-true and if-false actions.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:27:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317146#M94880</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-19T16:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a Variable from an Eval match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317147#M94881</link>
      <description>&lt;P&gt;This works. And I think would be my first choice of solution. Not sure if I can accept this as the solution or not though. &lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 17:05:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317147#M94881</guid>
      <dc:creator>stakor</dc:creator>
      <dc:date>2017-07-19T17:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a Variable from an Eval match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317148#M94882</link>
      <description>&lt;P&gt;Now you should be.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 18:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-set-a-Variable-from-an-Eval-match/m-p/317148#M94882</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-07-19T18:07:26Z</dc:date>
    </item>
  </channel>
</rss>

