<?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 Splunk Enterprise Security: Can you provide a function which returns a string in an if statement? in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210312#M1209</link>
    <description>&lt;P&gt;Can you provide a function which returns a string in an if statement? For example: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;if(src=="-" OR src=="127.0.0.1", Computer, trim(Source_Workstation,"some string"))&lt;/CODE&gt;, reads as:&lt;/P&gt;

&lt;P&gt;if src = - or 127.0.0.1, return the value of the Computer field. Else, return as string value of trim, where some string has been removed. &lt;/P&gt;

&lt;P&gt;When I run this eval, the first result performs as expected.  However, the trim statement returns 1 or 0.  In testing, this reports whether the &lt;CODE&gt;trim&lt;/CODE&gt; actually trimmed anything (1 for yes, 0 for no).  If I pipe as separate command, then I get the expected results (e.g. eval &lt;CODE&gt;src=trim(Source_Workstation,"some string"))&lt;/CODE&gt;.  However, I want this to be in a calculated field extraction and I can't seem to have multiple calculations running over the same field (makes sense).  This is an attempt to remove the leading "::ffff:" from some Windows event logs. &lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2016 13:44:31 GMT</pubDate>
    <dc:creator>panovattack</dc:creator>
    <dc:date>2016-11-04T13:44:31Z</dc:date>
    <item>
      <title>Splunk Enterprise Security: Can you provide a function which returns a string in an if statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210312#M1209</link>
      <description>&lt;P&gt;Can you provide a function which returns a string in an if statement? For example: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;if(src=="-" OR src=="127.0.0.1", Computer, trim(Source_Workstation,"some string"))&lt;/CODE&gt;, reads as:&lt;/P&gt;

&lt;P&gt;if src = - or 127.0.0.1, return the value of the Computer field. Else, return as string value of trim, where some string has been removed. &lt;/P&gt;

&lt;P&gt;When I run this eval, the first result performs as expected.  However, the trim statement returns 1 or 0.  In testing, this reports whether the &lt;CODE&gt;trim&lt;/CODE&gt; actually trimmed anything (1 for yes, 0 for no).  If I pipe as separate command, then I get the expected results (e.g. eval &lt;CODE&gt;src=trim(Source_Workstation,"some string"))&lt;/CODE&gt;.  However, I want this to be in a calculated field extraction and I can't seem to have multiple calculations running over the same field (makes sense).  This is an attempt to remove the leading "::ffff:" from some Windows event logs. &lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 13:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210312#M1209</guid>
      <dc:creator>panovattack</dc:creator>
      <dc:date>2016-11-04T13:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Enterprise Security: Can you provide a function which returns a string in an if statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210313#M1210</link>
      <description>&lt;P&gt;You could try rex instead using mode=sed.  Assuming the field you are working on is the Source_Workstation, that would be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex mode=sed field=Source_Workstation "s/^::ffff://"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The rex string says to &lt;CODE&gt;s&lt;/CODE&gt; substitute whenever you see what's between the first two slashes &lt;CODE&gt;^::ffff:&lt;/CODE&gt; (the carrot means at the start of that field) the values between the second two (which is empty). &lt;/P&gt;

&lt;P&gt;I don't have test data that matches yours right now, so I'm guessing.  You can try dropping off the &lt;CODE&gt;^&lt;/CODE&gt; at the front if it doesn't work with it.  Otherwise, if you can paste in a couple of the actual strings I can tweak it a bit if necessary.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 02:38:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210313#M1210</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-11-05T02:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Enterprise Security: Can you provide a function which returns a string in an if statement?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210314#M1211</link>
      <description>&lt;P&gt;I was able to solve by appending a dollar sign to the field name $somefield from the sub search e.g. [search * | table foo | return $foo]&lt;/P&gt;</description>
      <pubDate>Sun, 26 Feb 2017 14:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Enterprise-Security-Can-you-provide-a-function-which/m-p/210314#M1211</guid>
      <dc:creator>panovattack</dc:creator>
      <dc:date>2017-02-26T14:50:59Z</dc:date>
    </item>
  </channel>
</rss>

