<?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: Extracting calculated fields from an XML input doesn't work in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267441#M80458</link>
    <description>&lt;P&gt;I also tried to use FIELDALIAS. The fields are aliased quite well, but the EVAL (working in search strings) is not working in props.conf :(.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Oct 2015 18:11:09 GMT</pubDate>
    <dc:creator>arkadyz1</dc:creator>
    <dc:date>2015-10-09T18:11:09Z</dc:date>
    <item>
      <title>Extracting calculated fields from an XML input doesn't work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267437#M80454</link>
      <description>&lt;P&gt;I'm trying to extract some fields from an XML input. The sourcetype is set up correctly, and I get all kinds of extracted fields with long names such as &lt;CODE&gt;objectdata.general.timestamp&lt;/CODE&gt;, &lt;CODE&gt;objectdata.general.width{@unit}&lt;/CODE&gt; etc. My problem is this: calculated fields simply don't pick up the field names extracted from XML. For example, if I have an event looking like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;objectdata&amp;gt;
...
  &amp;lt;general&amp;gt;
  ...
    &amp;lt;width unit="inch"&amp;gt;
      &amp;lt;value&amp;gt;17.3&amp;lt;/value&amp;gt;
    &amp;lt;/width&amp;gt;
    ...
  &amp;lt;/general&amp;gt;
  ...
&amp;lt;/objectdata&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In search, I see &lt;CODE&gt;objectdata.general.width{@unit}&lt;/CODE&gt; as 'inch' and &lt;CODE&gt;objectdata.general.width.value&lt;/CODE&gt; as 17.3. However, some of the objects have their width in 'mm', which, of course, needs to be divided by 25.4 to be converted to inches.&lt;/P&gt;

&lt;P&gt;I wanted to calculate a new field and put this calculation in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-objectWidth = objectdata.general.width.value / if(objectdata.general.width{@unit}=='mm',25.4,1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but it doesn't work. No &lt;CODE&gt;objectWidth&lt;/CODE&gt; field is created. I suspect it has something to do with the order of field extractions and evaluations in the pipeline. Is there a reasonable way to achieve what I want without putting the calculations into the search command each time?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 17:26:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267437#M80454</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2015-10-08T17:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting calculated fields from an XML input doesn't work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267438#M80455</link>
      <description>&lt;P&gt;It's likely due to the field names containing special characters. You could use a fieldalias to rename the fields, and then do the EVAL with the renamed fields, or you could try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-objectWidth = 'objectdata.general.width.value' /  (if('objectdata.general.width{@unit}'="mm",25.4,1))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;FYI I have not tested the above EVAL expression&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 18:26:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267438#M80455</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-10-08T18:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting calculated fields from an XML input doesn't work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267439#M80456</link>
      <description>&lt;P&gt;Troubleshooting tip: Test the EVAL in search and get it to work there before putting it into props.conf &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 18:27:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267439#M80456</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-10-08T18:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting calculated fields from an XML input doesn't work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267440#M80457</link>
      <description>&lt;P&gt;First of all, those single quotes around the names helped me in at least one other place - I had to distinguish between &lt;CODE&gt;objectdata.timestamp&lt;/CODE&gt; and &lt;CODE&gt;objectdata.general.timestamp&lt;/CODE&gt;, and &lt;CODE&gt;EVAL-MyTimestamp='objectdata.general.timestamp'&lt;/CODE&gt; did solve this (I was not using single quotes previously).&lt;/P&gt;

&lt;P&gt;However, the more complex eval with the &lt;CODE&gt;if&lt;/CODE&gt; did not benefit enough from those - no field generated :(. And the eval does work from the search string! I tried both &lt;CODE&gt;==&lt;/CODE&gt; and a single &lt;CODE&gt;=&lt;/CODE&gt; as a comparison operator in &lt;CODE&gt;props.conf&lt;/CODE&gt; to no avail. Search string accepts the C-style comparison (==) just fine.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 18:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267440#M80457</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2015-10-08T18:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting calculated fields from an XML input doesn't work</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267441#M80458</link>
      <description>&lt;P&gt;I also tried to use FIELDALIAS. The fields are aliased quite well, but the EVAL (working in search strings) is not working in props.conf :(.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 18:11:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-calculated-fields-from-an-XML-input-doesn-t-work/m-p/267441#M80458</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2015-10-09T18:11:09Z</dc:date>
    </item>
  </channel>
</rss>

