<?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: Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78256#M763</link>
    <description>&lt;P&gt;You can't create a field alias that only operates when certain conditions are met.&lt;/P&gt;

&lt;P&gt;However, you could do a number of things that might accomplish what you want... what are you trying to accomplish?&lt;/P&gt;

&lt;P&gt;You could just rename the field whenever you use it in the context of EventCode=1234:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventCode=1234 | rename Account_Name as myAlias
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could do the following as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| eval myAlias=if(eventCode=="1234",Account_Name,null())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above &lt;CODE&gt;eval&lt;/CODE&gt; statement only creates the myAlias field when the eventCode is 1234. You could even put the &lt;CODE&gt;eval&lt;/CODE&gt; statement in a macro, so you wouldn't have to type it...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere | `setAlias`
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Jun 2013 20:36:54 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2013-06-27T20:36:54Z</dc:date>
    <item>
      <title>Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78255#M762</link>
      <description>&lt;P&gt;I want to alias Account_Name field for specific EventCode&lt;/P&gt;

&lt;P&gt;e.g. EventCode=1234 &lt;/P&gt;

&lt;P&gt;I want to find that event and alias Account_Name field of that event to lets say myAlias. These events are already in the index so I would like to extract them. Any suggestions how? &lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 18:49:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78255#M762</guid>
      <dc:creator>rbhatia</dc:creator>
      <dc:date>2013-06-27T18:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78256#M763</link>
      <description>&lt;P&gt;You can't create a field alias that only operates when certain conditions are met.&lt;/P&gt;

&lt;P&gt;However, you could do a number of things that might accomplish what you want... what are you trying to accomplish?&lt;/P&gt;

&lt;P&gt;You could just rename the field whenever you use it in the context of EventCode=1234:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventCode=1234 | rename Account_Name as myAlias
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could do the following as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| eval myAlias=if(eventCode=="1234",Account_Name,null())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above &lt;CODE&gt;eval&lt;/CODE&gt; statement only creates the myAlias field when the eventCode is 1234. You could even put the &lt;CODE&gt;eval&lt;/CODE&gt; statement in a macro, so you wouldn't have to type it...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere | `setAlias`
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jun 2013 20:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78256#M763</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-06-27T20:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78257#M764</link>
      <description>&lt;P&gt;Thanks a lot. But I would like to do this through props.conf and transforms.conf?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 00:11:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78257#M764</guid>
      <dc:creator>rbhatia</dc:creator>
      <dc:date>2013-06-28T00:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78258#M765</link>
      <description>&lt;P&gt;You could set the field alias in props.conf, but you can't do it for only EventCode=1234.&lt;BR /&gt;
That is, unless you want to assign that EventCode to a completely different sourcetype.&lt;BR /&gt;
You could put this in props.conf&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[thesourcetypehere]&lt;BR /&gt;
FIELDALIAS = Account_Name AS myAlias&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but that would create the myAlias field for all events in the sourcetype, not just those with EventCode=1234&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 02:39:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78258#M765</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-06-28T02:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78259#M766</link>
      <description>&lt;P&gt;Hi lguinn, &lt;/P&gt;

&lt;P&gt;Thanks for your answer. I tried FIELDALIAS already but as you mentioned, it created Alias for all the events. But I was able to find the solution. Rather that creating an alias, I created an Extraction result with multiline regex&lt;/P&gt;

&lt;P&gt;EXTRACT-test = (?ms)EventCode=1234.*Group:[\r\n]+(?:\t[^\r\n]+[\r\n]+)\t+Account\sName:\s+(?&lt;MYALIAS&gt;[^\r\n]+)&lt;/MYALIAS&gt;&lt;/P&gt;

&lt;P&gt;This worked for me. I found this in one of the threads in splunk-base. Thanks again for your reply.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 16:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78259#M766</guid>
      <dc:creator>rbhatia</dc:creator>
      <dc:date>2013-06-28T16:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract events for a specific EventCode from sourcetype=WinEventLog:Security and alias Account_Name to myAlias</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78260#M767</link>
      <description>&lt;P&gt;BTW just realized after posting the message all the r and n should be back slash \r and backslash \n.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2013 16:53:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Extract-events-for-a-specific-EventCode-from-sourcetype/m-p/78260#M767</guid>
      <dc:creator>rbhatia</dc:creator>
      <dc:date>2013-06-28T16:53:17Z</dc:date>
    </item>
  </channel>
</rss>

