<?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 create an eval for a field if it does not exist? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639977#M109255</link>
    <description>&lt;P&gt;It is likely that it is already done correctly for you if this is typical Enterprise software generating the data and you have the matching TAs installed everywhere.&amp;nbsp; In other words, "src_user" and "user" are typically different because it is "src_user" (e.g. "admin") doing something TO some other "user".&amp;nbsp; In any case, the reason that your calculated search is not working is because of this:&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Searchtimeoperationssequence" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Searchtimeoperationssequence&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2023 18:04:55 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2023-04-14T18:04:55Z</dc:date>
    <item>
      <title>How to create an eval for a field if it does not exist?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639874#M109249</link>
      <description>&lt;P&gt;I am in the process of normalizing data, so I can apply it to a data model. One of the fields which is having issues is called &lt;STRONG&gt;user&lt;/STRONG&gt;.&lt;BR /&gt;&lt;BR /&gt;I have user data in some logs, while other logs have an empty user field - but do have data in a &lt;STRONG&gt;src_user&lt;/STRONG&gt; field.&lt;/P&gt;
&lt;P&gt;Tried using the coalesce command - but that does not seem to work.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;EVAL-user = coalesce(user, src_user)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is it because I am trying to reference the &lt;STRONG&gt;user&lt;/STRONG&gt; field?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Are there any other work arounds to create a &lt;STRONG&gt;user&lt;/STRONG&gt; field when it is empty and filling data from src_user ? Remember, some logs have valid data in the user field. Others have no data.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 16:23:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639874#M109249</guid>
      <dc:creator>mjuestel2</dc:creator>
      <dc:date>2023-04-14T16:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an EVAL for a field if it does not exist</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639914#M109251</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/47276"&gt;@mjuestel2&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;to normalize the src_user field from the user field you can use an alias field (this is the usual approach to missing fields or fields with a wrong name).&lt;/P&gt;&lt;P&gt;If instead there are some events that have the src_user and some others that don't have it, you can use the coalesce option in eval.&lt;/P&gt;&lt;P&gt;If it doesan't run, you can use a calculated field like the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval src_user=if(isnull(src_user),user,src_user)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 07:07:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639914#M109251</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-04-14T07:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an eval for a field if it does not exist?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639977#M109255</link>
      <description>&lt;P&gt;It is likely that it is already done correctly for you if this is typical Enterprise software generating the data and you have the matching TAs installed everywhere.&amp;nbsp; In other words, "src_user" and "user" are typically different because it is "src_user" (e.g. "admin") doing something TO some other "user".&amp;nbsp; In any case, the reason that your calculated search is not working is because of this:&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Searchtimeoperationssequence" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Searchtimeoperationssequence&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 18:04:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-an-eval-for-a-field-if-it-does-not-exist/m-p/639977#M109255</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-14T18:04:55Z</dc:date>
    </item>
  </channel>
</rss>

