<?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 do i display the latest event from two event IDs by computer name? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424975#M121860</link>
    <description>&lt;P&gt;Hello, thank you for getting back to me, &lt;BR /&gt;
Thats working as follows;&lt;/P&gt;

&lt;P&gt;Machine Backedup                    Event Code&lt;BR /&gt;
DCAOVSG001                                22&lt;BR /&gt;
DCAOVSG002                                21&lt;BR /&gt;
DCAOVSG003                                21&lt;/P&gt;

&lt;P&gt;Which is the basis of what i am after, i just need to change the 21 to pass, 22 to fail message and then add a date. &lt;/P&gt;

&lt;P&gt;So what ive done is added &lt;BR /&gt;
 | eval Outcome=if(EventCode=21,"Success","Fail") &lt;BR /&gt;
 | fields - EventCode &lt;BR /&gt;
 | convert ctime("Date")|rename Machine_BackedUp as "Computer Name"&lt;/P&gt;

&lt;P&gt;onto the bottom of your search so that it looks like this:&lt;/P&gt;

&lt;P&gt;index=windows_health-servers sourcetype="WinEventLog:Application" (EventCode=21 OR EventCode=22) &lt;BR /&gt;
  | where match(Machine_BackedUp,"DC(A|P)OV\w{2}\d{3}") &lt;BR /&gt;
  | stats latest(EventCode) as EventCode by Machine_BackedUp&lt;BR /&gt;
  | eval Outcome=if(EventCode=21,"Success","Fail") &lt;BR /&gt;
  | fields - EventCode &lt;BR /&gt;
  | convert ctime("Date")|rename Machine_BackedUp as "Computer Name"&lt;/P&gt;

&lt;P&gt;i need to sort the time out by you my good sir are both a scholar and a gent. Thank you ever so much. &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:19:39 GMT</pubDate>
    <dc:creator>willsy</dc:creator>
    <dc:date>2020-09-29T22:19:39Z</dc:date>
    <item>
      <title>How do i display the latest event from two event IDs by computer name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424971#M121856</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I am trying to complete a query that allows me to see both the latest failed and successful backups from event logs for each computer. The issue i am having is that when i run the query i get both the failed and successful backups for the computer not just the most recent failure or success. &lt;/P&gt;

&lt;P&gt;for example if server A fails to backup, but then the backup is re-run and it passes i only want to see that it passes, Or on the flip side to that, if Server A successfully backs up and then fails at a different time, i would like to see that its most recent event is a failure. &lt;/P&gt;

&lt;P&gt;in my example eventcode 21 is a success, event code 22 is a failure. &lt;/P&gt;

&lt;P&gt;index=windows_health-servers sourcetype="WinEventLog:Application" (EventCode=21 OR EventCode=22) &lt;BR /&gt;
| where match(Machine_BackedUp,"DC(A|P)OV\w{2}\d{3}")&lt;BR /&gt;&lt;BR /&gt;
| eval Outcome=if(EventCode=21,"Success","Fail") &lt;BR /&gt;
|chart  values(Machine_BackedUp)  as "Computer Name" latest(EventCode)  as EventCode  latest(_time) as Date by Outcome &lt;BR /&gt;
| fields - EventCode &lt;BR /&gt;
| convert ctime("Date")&lt;/P&gt;

&lt;P&gt;Any help is greatly appreciated. &lt;/P&gt;

&lt;P&gt;Willsy&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:18:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424971#M121856</guid>
      <dc:creator>willsy</dc:creator>
      <dc:date>2020-09-29T22:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do i display the latest event from two event IDs by computer name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424972#M121857</link>
      <description>&lt;P&gt;@willsy,&lt;BR /&gt;
Try moving the chart/stats before the Outcome eval&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=windows_health-servers sourcetype="WinEventLog:Application" (EventCode=21 OR EventCode=22) 
| where match(Machine_BackedUp,"DC(A|P)OV\w{2}\d{3}") 
| stats latest(EventCode) as EventCode,latest(_time) as Date by Machine_BackedUp
| eval Outcome=if(EventCode=21,"Success","Fail") 
| fields - EventCode 
| convert ctime("Date")|rename Machine_BackedUp as "Computer Name"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 18:44:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424972#M121857</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-12-06T18:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do i display the latest event from two event IDs by computer name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424973#M121858</link>
      <description>&lt;P&gt;Thats certainly alot better than what i had before, so thank you for that. The individual events are there but i still have in the search &lt;/P&gt;

&lt;P&gt;DCAOVSG001 failed backup 12/06/2018&lt;BR /&gt;
DCAOVSG001 successfull backup 12/07/2018&lt;/P&gt;

&lt;P&gt;is there a way, that i can only see the very latest one? so in this case i would only see the successful backup as opposed to both? &lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 08:44:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424973#M121858</guid>
      <dc:creator>willsy</dc:creator>
      <dc:date>2018-12-07T08:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do i display the latest event from two event IDs by computer name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424974#M121859</link>
      <description>&lt;P&gt;@willsy, are you adding date or any other field in the &lt;CODE&gt;by&lt;/CODE&gt; clause?&lt;/P&gt;

&lt;P&gt;Just to test, can you try this ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=windows_health-servers sourcetype="WinEventLog:Application" (EventCode=21 OR EventCode=22) 
 | where match(Machine_BackedUp,"DC(A|P)OV\w{2}\d{3}") 
 | stats latest(EventCode) as EventCode by Machine_BackedUp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is it displaying both eventcodes for machine DCAOVSG001 ?&lt;/P&gt;</description>
      <pubDate>Sat, 08 Dec 2018 09:19:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424974#M121859</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-12-08T09:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do i display the latest event from two event IDs by computer name?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424975#M121860</link>
      <description>&lt;P&gt;Hello, thank you for getting back to me, &lt;BR /&gt;
Thats working as follows;&lt;/P&gt;

&lt;P&gt;Machine Backedup                    Event Code&lt;BR /&gt;
DCAOVSG001                                22&lt;BR /&gt;
DCAOVSG002                                21&lt;BR /&gt;
DCAOVSG003                                21&lt;/P&gt;

&lt;P&gt;Which is the basis of what i am after, i just need to change the 21 to pass, 22 to fail message and then add a date. &lt;/P&gt;

&lt;P&gt;So what ive done is added &lt;BR /&gt;
 | eval Outcome=if(EventCode=21,"Success","Fail") &lt;BR /&gt;
 | fields - EventCode &lt;BR /&gt;
 | convert ctime("Date")|rename Machine_BackedUp as "Computer Name"&lt;/P&gt;

&lt;P&gt;onto the bottom of your search so that it looks like this:&lt;/P&gt;

&lt;P&gt;index=windows_health-servers sourcetype="WinEventLog:Application" (EventCode=21 OR EventCode=22) &lt;BR /&gt;
  | where match(Machine_BackedUp,"DC(A|P)OV\w{2}\d{3}") &lt;BR /&gt;
  | stats latest(EventCode) as EventCode by Machine_BackedUp&lt;BR /&gt;
  | eval Outcome=if(EventCode=21,"Success","Fail") &lt;BR /&gt;
  | fields - EventCode &lt;BR /&gt;
  | convert ctime("Date")|rename Machine_BackedUp as "Computer Name"&lt;/P&gt;

&lt;P&gt;i need to sort the time out by you my good sir are both a scholar and a gent. Thank you ever so much. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:19:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-i-display-the-latest-event-from-two-event-IDs-by-computer/m-p/424975#M121860</guid>
      <dc:creator>willsy</dc:creator>
      <dc:date>2020-09-29T22:19:39Z</dc:date>
    </item>
  </channel>
</rss>

