<?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: Search for Error only in the latest log file coming from different hosts in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338858#M100481</link>
    <description>&lt;P&gt;Thanks Esix,&lt;/P&gt;

&lt;P&gt;Tried using latest; but not able to get the errors from the latest log file produced by unique cid extracted using the rex at search time.  I have put my use-case in more detail in the comments to deepashri_123.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Mar 2018 06:07:54 GMT</pubDate>
    <dc:creator>nmohammed</dc:creator>
    <dc:date>2018-03-13T06:07:54Z</dc:date>
    <item>
      <title>Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338852#M100475</link>
      <description>&lt;P&gt;My original search Query returns results- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ver_logs"  "ERORR detected" | rex field=source "VerLogs\\\(?.*?)\_"  | stats count by cid, host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but we only want to get results from the latest log file for each cid. &lt;/P&gt;

&lt;P&gt;Appreciate your help.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 21:26:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338852#M100475</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2018-03-11T21:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338853#M100476</link>
      <description>&lt;P&gt;Corrected the rex extraction for field -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ver_logs" "ERORR detected" | rex field=source "VerLogs\\\(?.*?)\_" | stats count by cid, host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Mar 2018 21:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338853#M100476</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2018-03-11T21:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338854#M100477</link>
      <description>&lt;P&gt;By the latest log file, do you mean the most recent log file? &lt;/P&gt;

&lt;P&gt;Splunk data is indexed based on time series data. This means that as you search data, and as long as you have it indexed based on the proper event time stamps, then the results you get will be displayed in the time from latest to oldest. (In your results view.) &lt;/P&gt;

&lt;P&gt;Drilling down a bit more without understanding your use case fully, you can also you the &lt;STRONG&gt;latest&lt;/STRONG&gt; Event Order command in your stats pipeline in order to get the latest events based on the fields of your choosing : &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/Eventorderfunctions"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/Eventorderfunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Those are a few options there...&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 04:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338854#M100477</guid>
      <dc:creator>esix_splunk</dc:creator>
      <dc:date>2018-03-12T04:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338855#M100478</link>
      <description>&lt;P&gt;Hey nmohammed,&lt;/P&gt;

&lt;P&gt;Are you trying something like this:&lt;/P&gt;

&lt;P&gt;index="ver_logs"  "ERROR detected" | rex field=source "VerLogs\(?.*?)_"  | stats latest(cid) AS cid by host | stats count(cid) AS count values(cid) AS cid by host&lt;/P&gt;

&lt;P&gt;Let me know if this helps!!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 08:36:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338855#M100478</guid>
      <dc:creator>deepashri_123</dc:creator>
      <dc:date>2018-03-12T08:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338856#M100479</link>
      <description>&lt;P&gt;Thanks Deepashri_123&lt;/P&gt;

&lt;P&gt;I will try to explain my use-case :&lt;/P&gt;

&lt;P&gt;1.We've multiple servers and on each server there are logs produced by our app during upgrades. &lt;BR /&gt;
2. Each Log is identified by unique cid_date_time.log&lt;/P&gt;

&lt;P&gt;D:\Logs\VerLogs\fe1234_3122018_233050.log&lt;BR /&gt;
D:\Logs\VerLogs\fe1234_3122018_231020.log&lt;BR /&gt;
D:\Logs\VerLogs\fe5678_3122018_212030.log&lt;BR /&gt;
D:\Logs\VerLogs\fe5678_3122018_231020.log&lt;/P&gt;

&lt;P&gt;Sometimes during our app upgrades , we run into errors. So, a redeployment is neede which is usually in a very shortly after the first failure scan.  After re-doing the upgrade, we again want to validate from the newest log file (source) for each cid. The "cid" is unique and I am extracting it during search-time using the "rex" command. &lt;/P&gt;

&lt;P&gt;It was easy to run a query and look for errors, but it scans all the logs available. Unfortunately, we only to validate if there are any errors from the newest log file produced by a cid.  &lt;/P&gt;

&lt;P&gt;In the above 4 log files; we saw error in the first log (D:\Logs\VerLogs\fe1234_3122018_191020.log), then after re-deployment there were no errors in the second log file (D:\Logs\VerLogs\fe1234_3122018_231020.log).  These times may change and for some "cid" there may not be any errors as first attempt to upgrade can be successful. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:25:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338856#M100479</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2020-09-29T18:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338857#M100480</link>
      <description>&lt;P&gt;The data is indexed properly without any issues.&lt;BR /&gt;
Example data -&lt;/P&gt;

&lt;P&gt;[3/10/2018 11:32:34 PM] ERROR detected SQL migration failed, deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 06:05:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338857#M100480</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2018-03-13T06:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338858#M100481</link>
      <description>&lt;P&gt;Thanks Esix,&lt;/P&gt;

&lt;P&gt;Tried using latest; but not able to get the errors from the latest log file produced by unique cid extracted using the rex at search time.  I have put my use-case in more detail in the comments to deepashri_123.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 06:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338858#M100481</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2018-03-13T06:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338859#M100482</link>
      <description>&lt;P&gt;@nmohammed have you tried the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="ver_logs"  "ERORR detected"
| rex field=source "VerLogs\\\(?&amp;lt;cid&amp;gt;[^\_]+)\_" 
| dedup cid host
| table cid host _time _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;[Updated]&lt;/P&gt;

&lt;P&gt;Added the rex to extract cid&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 09:03:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338859#M100482</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-13T09:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338860#M100483</link>
      <description>&lt;P&gt;@niketniley&lt;/P&gt;

&lt;P&gt;it did not help. So, what I am trying to do is.. search for any errors in the latest log file produced by each "cid".  Some "cid" don't have errors and some do. When we run a regular search it does return only those cids which have error.&lt;BR /&gt;
"index="ver_logs"  "ERORR detected" | rex field=source "VerLogs\(?.*?)_"  | stats count by cid, host" &lt;/P&gt;

&lt;P&gt;but we look at the list of all "cid" obtained from above search and fix them running an upgrade which produces another log file for that "cid" which does not have error.  So, in order to validate we should only run searches against the newest log file produced by each cid for any error occurrence.  &lt;/P&gt;

&lt;P&gt;Thanks for your input. &lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 03:29:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338860#M100483</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2018-03-14T03:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338861#M100484</link>
      <description>&lt;P&gt;Hey nmohammed,&lt;/P&gt;

&lt;P&gt;I am not sure if this will work:&lt;BR /&gt;
Can you try something like this:&lt;BR /&gt;
index=ver_logs  [search index=ver_logs | dedup _time | head 1 | return _time]  &lt;/P&gt;

&lt;P&gt;Let me know if this gives you result of only latest source.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:28:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338861#M100484</guid>
      <dc:creator>deepashri_123</dc:creator>
      <dc:date>2020-09-29T18:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338862#M100485</link>
      <description>&lt;P&gt;hi @deepashri_123&lt;/P&gt;

&lt;P&gt;Doesn't give the results I want to see. Thanks for helping though.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:22:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338862#M100485</guid>
      <dc:creator>nmohammed</dc:creator>
      <dc:date>2018-03-14T18:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Search for Error only in the latest log file coming from different hosts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338863#M100486</link>
      <description>&lt;P&gt;@nmohammed did you try with your rex for finiding cid as well?&lt;/P&gt;

&lt;P&gt;The dedup command actually retains only the latest row based on the dedup criteria. This is based on the fact that latest event will be displayed first in Splunk (reverse chronological order of time). In this case I assumed cid + host should give unique record and that you would be interested only in the latest.&lt;/P&gt;

&lt;P&gt;When you say &lt;CODE&gt;it did not help&lt;/CODE&gt;, what is the output of query vs what is the expected output?&lt;/P&gt;

&lt;P&gt;Also can you add sample data the scenario across multiple hosts where cid has error first and then it is fixed? &lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 20:20:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-Error-only-in-the-latest-log-file-coming-from/m-p/338863#M100486</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-14T20:20:48Z</dc:date>
    </item>
  </channel>
</rss>

