<?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: Same fields with different values in one event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13757#M1365</link>
    <description>&lt;P&gt;I can't delete others comments.  I removed mine.  (and I can remove this one later)&lt;/P&gt;</description>
    <pubDate>Wed, 19 May 2010 21:45:16 GMT</pubDate>
    <dc:creator>Lowell</dc:creator>
    <dc:date>2010-05-19T21:45:16Z</dc:date>
    <item>
      <title>Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13750#M1358</link>
      <description>&lt;P&gt;In the following Windows event log message field Account Name appears twice with different values. When I build a report by Account Name it looks like there were two events instead of one, because Splunk is indexing Account Name twice in this case.&lt;/P&gt;

&lt;P&gt;Is there a way to avoid indexing the first one (under subject)?&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;LogName=SecuritySourceName=Microsoft Windows security auditing.&lt;/P&gt;

&lt;P&gt;EventCode=4625&lt;/P&gt;

&lt;P&gt;EventType=0&lt;/P&gt;

&lt;P&gt;Type=Information&lt;/P&gt;

&lt;P&gt;ComputerName=AD1.TEIG.production&lt;/P&gt;

&lt;P&gt;TaskCategory=Logon&lt;/P&gt;

&lt;P&gt;OpCode=Info&lt;/P&gt;

&lt;P&gt;RecordNumber=1371401&lt;/P&gt;

&lt;P&gt;Keywords=Audit&lt;/P&gt;

&lt;P&gt;FailureMessage=An account failed to log on.&lt;/P&gt;

&lt;P&gt;Subject:&lt;/P&gt;

&lt;P&gt;Security ID:        S-1-0-0&lt;/P&gt;

&lt;P&gt;Account Name:       -&lt;/P&gt;

&lt;P&gt;Account Domain:     -&lt;/P&gt;

&lt;P&gt;Logon ID:       0x0&lt;/P&gt;

&lt;P&gt;Logon Type:         3&lt;/P&gt;

&lt;P&gt;Account For Which Logon Failed:&lt;/P&gt;

&lt;P&gt;Security ID:        S-1-0-0&lt;/P&gt;

&lt;P&gt;Account Name:       APP2$&lt;/P&gt;

&lt;P&gt;Account Domain:     TEIG.PRODUCTIONFailure&lt;/P&gt;

&lt;P&gt;Information:    Failure&lt;/P&gt;

&lt;P&gt;Reason:     An Error occured during Logon.&lt;/P&gt;

&lt;P&gt;Status:         0xc0000133&lt;/P&gt;

&lt;P&gt;Sub Status:     0x0&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 19:57:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13750#M1358</guid>
      <dc:creator>kkuminsky</dc:creator>
      <dc:date>2010-05-18T19:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13751#M1359</link>
      <description>&lt;P&gt;I don't think your issue is that splunk is indexing your event multiple times.  Splunk will only index an event once.  I think your questions is really about &lt;A href="http://www.splunk.com/base/Documentation/4.0/Knowledge/Addfieldsatsearchtime" rel="nofollow"&gt;field extraction&lt;/A&gt; and multi-value fields.  For &lt;CODE&gt;WinEventLog:Security&lt;/CODE&gt; events, splunk already has setup the necessary field-extraction rules for you, so all the fields you needs should already be available.  However, I think what you hitting is the fact that splunk allows multiple value for these fields.  (Which is generally preferable over silently dropping one of the values.)&lt;/P&gt;

&lt;P&gt;I'm assuming that in your example, your are ending up with a multi-value field named &lt;CODE&gt;Account_Name&lt;/CODE&gt; that contains the values of '-' and &lt;CODE&gt;APP2$&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;So what you probably want to do is simply drop the &lt;CODE&gt;"-"&lt;/CODE&gt; value, which can be done a couple of different ways.  You can build your chart or report and simply drop the "-" value after the fact.  Or you can tell splunk to keep only the first or last value of a multi-value field, or filter the multi-value field.  Here are a few examples to give you an idea of what's possible:&lt;/P&gt;

&lt;P&gt;Keep only the first value:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" | eval Account_Name=mvindex(Account_Name, 0) | ...&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Keep only the last value:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" | eval Account_Name=mvindex(Account_Name, -1) | ...&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Remove out the "-" value using &lt;CODE&gt;mvfilter&lt;/CODE&gt;.  (I think this is probably the best option for you)&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" | eval Account_Name=mvindex(Account_Name!="-") | ...&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Remove out the "-" value (using a post-search command)&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" | stats count by Account_Name | search Account_Name!="-"&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Here is one last search that &lt;EM&gt;will NOT work&lt;/EM&gt; for what you want.  (I feel this is an important gotcha to understand when searching with multi-value fields)&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;sourcetype="WinEventLog:Security" Account_Name!="-" | ...&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Sometimes this may actually appear to work (based on how many events actually contain a dash value, vs how many event contain non-dash values).  Here is what's really going on here:  Any event that has a field named  &lt;CODE&gt;Account_Name&lt;/CODE&gt; where any of the multi-values is &lt;CODE&gt;"-"&lt;/CODE&gt; will be dropped from your search results.  Therefore, the example event that you provided will be excluded; which means that you will be loosing both the "-" &lt;EM&gt;and&lt;/EM&gt; "APP2$" at the same time.  So this approach is not what you want.&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Side note:&lt;/EM&gt; If you are fairly new to splunk, I would suggest that you play around with these different options until you get a better feel for how these different approaches work.  You may find that such an exercise will end up saving you time in future splunk searches.  Just a thought.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Additional resources:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.splunk.com/base/Documentation/4.0/SearchReference/CommonEvalFunctions" rel="nofollow"&gt;Functions for eval and where&lt;/A&gt; -- For more information about &lt;CODE&gt;mvindex&lt;/CODE&gt; and &lt;CODE&gt;mvfilter&lt;/CODE&gt; (and others).&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/User/ParseFieldsWithMultipleValues" rel="nofollow"&gt;Manipulate and evaluate fields with multiple values&lt;/A&gt; -- A more general introduction to dealing with multi-value fields.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 18 May 2010 20:33:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13751#M1359</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-18T20:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13752#M1360</link>
      <description>&lt;P&gt;An alternative way could be to remap the Account Name field with the following directive in &lt;EM&gt;props.conf&lt;/EM&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[WinEventLog:security]
EXTRACT-AccountName = Account Name:\s(?P&amp;lt;AccountName&amp;gt;[^\s^:^-]+)\s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will prevent to have something like "Account Name: -" recognized as another value for the Account name field.&lt;/P&gt;

&lt;P&gt;Regards,
Marco Scala&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 21:10:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13752#M1360</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2010-05-18T21:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13753#M1361</link>
      <description>&lt;P&gt;Note that your last last example ('Remove out the "-" value') will actually filter out the events that have both values,  not simply clean out the value.&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 22:00:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13753#M1361</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-05-18T22:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13754#M1362</link>
      <description>&lt;P&gt;Oh of course.  Sorry i missed that.  Feel free to delete this little comment failtrain.  my bad.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 14:03:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13754#M1362</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-05-19T14:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13755#M1363</link>
      <description>&lt;P&gt;Yes, this will work, and in previous versions of Splunk this may have been the best option.  Here's the downside:  You now have multiple fields with the same info (&lt;CODE&gt;AccountName&lt;/CODE&gt; and &lt;CODE&gt;Account_Name&lt;/CODE&gt;) and some extra regex overhead.  Also, if you do have events with multiple account names given (other than "-", of course), than this approach will only match the first one.  Perhaps this doesn't happen in this type of event, but it's something to think about.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 21:38:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13755#M1363</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-19T21:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13756#M1364</link>
      <description>&lt;P&gt;Your regex will also block any account name with a dash in it, not just "-".  For example, a value of "APP-2" doesn't match.  You could try this regex instead:  &lt;CODE&gt;EXTRACT-AccountName = ^\s*Account Name:\s(?P&amp;lt;AccountName&amp;gt;(?!-$).+)\s*$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 21:44:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13756#M1364</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-19T21:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13757#M1365</link>
      <description>&lt;P&gt;I can't delete others comments.  I removed mine.  (and I can remove this one later)&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2010 21:45:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13757#M1365</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-19T21:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13758#M1366</link>
      <description>&lt;P&gt;Guys, thank you for the detailed info. I'm new to splunk and I'm impressed by it's search functionality.&lt;/P&gt;

&lt;P&gt;So, I've adopted this one:&lt;/P&gt;

&lt;P&gt;eval Account_Name=mvindex(Account_Name, -1) | ...&lt;/P&gt;

&lt;P&gt;Mostly because:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;There are some events that have "-" value for both Account_name fields&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I'm expecting different values for the first account field, not only "-", but the one that I'm interested in is the second one.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 20 May 2010 00:02:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13758#M1366</guid>
      <dc:creator>kkuminsky</dc:creator>
      <dc:date>2010-05-20T00:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13759#M1367</link>
      <description>&lt;P&gt;Sounds like good reasoning to me.&lt;/P&gt;</description>
      <pubDate>Thu, 20 May 2010 00:20:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13759#M1367</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-05-20T00:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13760#M1368</link>
      <description>&lt;P&gt;this is useful! thanks Lowell.&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2010 17:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13760#M1368</guid>
      <dc:creator>marcoscala</dc:creator>
      <dc:date>2010-05-24T17:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13761#M1369</link>
      <description>&lt;P&gt;Great answer; loved the spl breakouts&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2014 20:34:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13761#M1369</guid>
      <dc:creator>essklau</dc:creator>
      <dc:date>2014-05-15T20:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Same fields with different values in one event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13762#M1370</link>
      <description>&lt;P&gt;That was then, this is now... and NOW you have mod rights so you CAN delete others comments :-).  Both of you! All of us!&lt;/P&gt;

&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2019 03:13:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Same-fields-with-different-values-in-one-event/m-p/13762#M1370</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2019-12-07T03:13:17Z</dc:date>
    </item>
  </channel>
</rss>

