<?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: Field Aliases and Extractions -- overlap or order of operations causing issue in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456003#M128922</link>
    <description>&lt;P&gt;A tricky thing that isn't obvious (but I don't think is your problem if the answer to my below question is yes) the part "username-esxi-extraction" is called a "class" and must be globally unique.  If there is another config anywhere that is "EXTRACT-username-esxi-extraction" whichever app/sourcetype comes first alphabetically will have "class" precedence.  &lt;/P&gt;

&lt;P&gt;When I develop my own stuff I'll start a schema like EXTRACT-custom_esxi_1, EXTRACT-custom_esxi_2, FIELDALIAS-custom_esxi_3, etc.  This way I'm nearly 100% sure it wont show up in a TA or App from Splunkbase and cause me problems.  &lt;/P&gt;

&lt;P&gt;So, to your problem, is this working in props or just in search? If in props, go ahead and set the config and use "username"&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;Messing around with it, I found that if I changed the "(?P&amp;lt;username&amp;gt;\w+)" to something like "(?P&amp;lt;xxxx&amp;gt;\w+)", it works!&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Then, comment out the existing alias&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;#FIELDALIAS-normalize_username_esxi_hostd = Username as username user AS username&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;and do this instead&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;EVAL-username = mvdedup(lower(mvappend('Username','user','username')))&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:39:25 GMT</pubDate>
    <dc:creator>marycordova</dc:creator>
    <dc:date>2020-09-30T00:39:25Z</dc:date>
    <item>
      <title>Field Aliases and Extractions -- overlap or order of operations causing issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456001#M128920</link>
      <description>&lt;P&gt;So I have an event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;164&amp;gt;2019-05-14T22:04:15.161Z hostname Hostd: Rejected password for user myuser from 192.168.1.10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The user field is not extracted automatically, so I created (via webUI) a extraction:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::VMware:esxlog:source::tcp:1514]
EXTRACT-username-esxi-extraction = (?=[^f]*(?:for user|f.*for user))^(?:[^ \n]* ){7}(?P&amp;lt;username&amp;gt;\w+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This extraction works great when I do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | rex "(?=[^f]*(?:for user|f.*for user))^(?:[^ \n]* ){7}(?P&amp;lt;username&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(See sample:  &lt;A href="https://www.regextester.com/?fam=109334"&gt;https://www.regextester.com/?fam=109334&lt;/A&gt;)&lt;BR /&gt;
Unfortunately, if I just run the search without the REX (the props.conf extraction should handle it fine), I get nothing.&lt;BR /&gt;
Messing around with it, I found that if I changed the &lt;CODE&gt;"(?P&amp;lt;username&amp;gt;\w+)"&lt;/CODE&gt; to something like &lt;CODE&gt;"(?P&amp;lt;xxxx&amp;gt;\w+)"&lt;/CODE&gt;, it works!&lt;/P&gt;

&lt;P&gt;So, I thought maybe there was some overlap, but I don't know how/why that would be an issue. I don't know what to look for in the btool readout -- it looks fine.&lt;/P&gt;

&lt;P&gt;So then I thought, ok! ill alias "xxxx" over to "username". Hacky, but I'm so tired of this stupid extraction by now, I don't even care.&lt;BR /&gt;
ANd that leads me to this clever alias:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[VMware:esxlog:Hostd]
FIELDALIAS-normalize_username_esxi_hostd = Username as username user AS username xxxx AS username
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this does nothing! the other 2 seem to still work (Username and user) but "xxxx" is a dud.&lt;BR /&gt;
I checked the order of things here:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Searchtimeoperationssequence"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Searchtimeoperationssequence&lt;/A&gt;&lt;BR /&gt;
I see no reason my alias would not work on an extracted field.&lt;/P&gt;

&lt;P&gt;Any suggestions or some glaring error I am missing?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 17:20:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456001#M128920</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2019-05-15T17:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Field Aliases and Extractions -- overlap or order of operations causing issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456002#M128921</link>
      <description>&lt;P&gt;Maybe an additional example now that I have had time to look into this some more.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Username: bob
         pc1
Date: 10-10-2019
Hostname: pc1
usr: bob
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need my end result to be "username" (not Username).&lt;BR /&gt;
So, I add "Username as username" to my fieldalias, but this wont work because this particular event has multiple values for the Username field (Both "bob" and "pc1").&lt;BR /&gt;
Good thing that the "usr" field exists!&lt;BR /&gt;
I add "usr as username" to my fieldalias.&lt;/P&gt;

&lt;P&gt;But: This wont work? Splunk will not allow 2 fieldaliases with the same destination?&lt;BR /&gt;
So what would I do in a situation where "Username" had better info, and "usr" didn't exist?&lt;BR /&gt;
In the actual search field, I can always "rename usr AS username", but I would like to have it done in the background, not in the actual search string.&lt;BR /&gt;
How would you normalize a field like this, where a sourcetype &lt;STRONG&gt;may&lt;/STRONG&gt; have 2 different fields that need to wind up in the same destination? Maybe not all of my events have "usr", but they do all have Username, but if "usr" exists, I definitely want to use it instead of Username.&lt;/P&gt;

&lt;P&gt;And with all of these questions, I find myself in a different place than when I made my original post. Same problem, but "normalization" just keeps getting harder.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 17:42:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456002#M128921</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2019-05-22T17:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Field Aliases and Extractions -- overlap or order of operations causing issue</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456003#M128922</link>
      <description>&lt;P&gt;A tricky thing that isn't obvious (but I don't think is your problem if the answer to my below question is yes) the part "username-esxi-extraction" is called a "class" and must be globally unique.  If there is another config anywhere that is "EXTRACT-username-esxi-extraction" whichever app/sourcetype comes first alphabetically will have "class" precedence.  &lt;/P&gt;

&lt;P&gt;When I develop my own stuff I'll start a schema like EXTRACT-custom_esxi_1, EXTRACT-custom_esxi_2, FIELDALIAS-custom_esxi_3, etc.  This way I'm nearly 100% sure it wont show up in a TA or App from Splunkbase and cause me problems.  &lt;/P&gt;

&lt;P&gt;So, to your problem, is this working in props or just in search? If in props, go ahead and set the config and use "username"&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;Messing around with it, I found that if I changed the "(?P&amp;lt;username&amp;gt;\w+)" to something like "(?P&amp;lt;xxxx&amp;gt;\w+)", it works!&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Then, comment out the existing alias&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;#FIELDALIAS-normalize_username_esxi_hostd = Username as username user AS username&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;and do this instead&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;EVAL-username = mvdedup(lower(mvappend('Username','user','username')))&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-Aliases-and-Extractions-overlap-or-order-of-operations/m-p/456003#M128922</guid>
      <dc:creator>marycordova</dc:creator>
      <dc:date>2020-09-30T00:39:25Z</dc:date>
    </item>
  </channel>
</rss>

