<?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 add a value to a fieldvalue if a certain field exists? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566088#M197257</link>
    <description>&lt;P&gt;Are you sure you're calling isnotnull on the right field? From what you describe you'd rather need&lt;/P&gt;&lt;PRE&gt;|eval maxport=if(isnotnull(fieldx),max_port+1,max_port)&lt;/PRE&gt;&lt;P&gt;And are you sure that you want a new column &lt;EM&gt;maxport&lt;/EM&gt; or do you want to overwrite &lt;EM&gt;max_port&lt;/EM&gt;?&lt;/P&gt;</description>
    <pubDate>Tue, 07 Sep 2021 08:08:41 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-09-07T08:08:41Z</dc:date>
    <item>
      <title>how to add a value to a fieldvalue if a certain field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566081#M197254</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;I struggle to find a way to add a value (for example 1) to a fieldvalue in case a certain field exists. Let's say this certain field is fieldx and it only exists and has a value, when you specifically block a port. After you've unblocked it, the field disappears.&lt;/P&gt;&lt;P&gt;what I'm currently looking at is a maxvalue of a field (for example the highest destination port number) so I go&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;index=firewall destport=*&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;|stats max(destport) as max_port&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;now I have my highest destination port. let's say it's 65000&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I'm now trying to accomplish is, that, if this port is currently blocked and the fieldx=blocked appears, I want to add a 1 to the max_port value -&amp;gt; 65001 and otherwise leave it be.&lt;BR /&gt;&lt;BR /&gt;I've tried an eval if&amp;nbsp; like that:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;|eval maxport=if(isnotnull(fieldx),max_port+1,max_port)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it doesn't work. do I have something wrong?&amp;nbsp;&lt;/P&gt;&lt;P&gt;ps: in reality I don't know what the value of the fieldx is, so I can't just if(fieldx==blocked,...). but since the field only appears if there is a value in it to begin with, I would use that to my advantage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also, is it possible to add the +1 only for a certain period of time ? for example add +1 to the value as long as it is in a two week frame ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 09:08:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566081#M197254</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2021-09-07T09:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a value to a fieldvalue if a certain field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566088#M197257</link>
      <description>&lt;P&gt;Are you sure you're calling isnotnull on the right field? From what you describe you'd rather need&lt;/P&gt;&lt;PRE&gt;|eval maxport=if(isnotnull(fieldx),max_port+1,max_port)&lt;/PRE&gt;&lt;P&gt;And are you sure that you want a new column &lt;EM&gt;maxport&lt;/EM&gt; or do you want to overwrite &lt;EM&gt;max_port&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 08:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566088#M197257</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-07T08:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a value to a fieldvalue if a certain field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566092#M197260</link>
      <description>&lt;P&gt;True! tnx, I edited my question. I meant to put fieldx in it, not max_port.&lt;BR /&gt;actually I want to overwrite maxport, the new field was just to show whether my eval works or not (it doesn't).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 08:26:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566092#M197260</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2021-09-07T08:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to add a value to a fieldvalue if a certain field exists?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566101#M197266</link>
      <description>&lt;P&gt;Well... should work&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval port=123 
| eval port=if(isnotnull(fieldx),port+1,port)&lt;/LI-CODE&gt;&lt;P&gt;Gives you port 123&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval port=123 
| eval fieldx="whatever"
| eval port=if(isnotnull(fieldx),port+1,port)&lt;/LI-CODE&gt;&lt;P&gt;Gives 124.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 09:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-add-a-value-to-a-fieldvalue-if-a-certain-field-exists/m-p/566101#M197266</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-07T09:35:30Z</dc:date>
    </item>
  </channel>
</rss>

