<?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: Breaking unusual log files in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12270#M957</link>
    <description>&lt;P&gt;If you're stuck with this kinda cross-threaded indexing picture, you can still index everything as single line events and use the search language to put things back together at search time.  This often seems like a consolation prize but in many ways it can actually be a better and more flexible way to go.  For instance for a long running transaction you get the start events into the index and your system has the power to detect the problem before the transaction closes.  &lt;/P&gt;

&lt;P&gt;One concrete problem is that you end up with some weird things like half of 8656 is at its own starttime, and the other half is indexed at the starttime of 10152.  Therefore for any particular timerange you may need to filter out transactions whose end was clipped off, or else your statistics might get skewed slightly.  &lt;/P&gt;

&lt;P&gt;So to be able to account for that Im going to assume that there's some endEvent=1 field that we extract when we see the final line.  And Im also assuming that you are correctly extracting the 'eventId' field out of the single line events, and other fields involved are getting extracted properly.  &lt;/P&gt;

&lt;P&gt;So here are 2 ways to do it.  For both examples lets say you're interested in the peakPageFileUsage and elapsedTime fields &lt;/P&gt;

&lt;P&gt;1) the transaction command can put this back together with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="foo" | transaction eventId maxspan=1m | search endEvent=1 | fields eventId peakPageFileUsage elapsedTime 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(the maxspan value you would use depends on how frequently the eventId's are reused by the system. )&lt;/P&gt;

&lt;P&gt;2) And stats is often overlooked but it can do a lot of this stuff just fine too. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="foo" | stats first(endEvent) first(peakPageFileUsage) first(elapsedTime) by eventId | search endEvent=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(and &lt;EM&gt;if&lt;/EM&gt; you ever have a field that appears multiple  times in a single eventId you could use the values() operator within stats and then operate on a multi-valued field from there. )&lt;/P&gt;</description>
    <pubDate>Mon, 26 Apr 2010 23:55:07 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2010-04-26T23:55:07Z</dc:date>
    <item>
      <title>Breaking unusual log files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12268#M955</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am having trouble breaking up the log file below:&lt;/P&gt;

&lt;P&gt;Each log entry starts with id:#################### and ends with id:@@@@@@@@@@@@@@@@&lt;/P&gt;

&lt;P&gt;However as you can see below the logs can be written to by to different processes at the same time, is there any way to have the logs broken as follows:&lt;/P&gt;

&lt;P&gt;Start an event with id:#################### and end only when you see the corresponding id ending e.g id:@@@@@@@@@@@@@@@@&lt;/P&gt;

&lt;P&gt;Also the log entries also have a start and a complete date, as Splunk by default breaks by date if we swtich this off is there a way to force Splunk to just take the start date as the event date?&lt;/P&gt;

&lt;P&gt;The start date proceeds the line id:####################&lt;/P&gt;

&lt;PRE&gt;
8656: ################################################
8656: From xxxxxx@xxxxxxxxx 31 Mar 2010 11:33:24 (pid=2768,TSRW.52.2,ditTradeBookManager)
8656: IN ### PagefileUsage: 46,508 K, PeakPagefileUsage: 52,756 K
8656: Fetch Trades For FIRM
8656: This user is GLOBAL hence executing the current Tradeserver Functionality 
8656:  with condition [BOOK in ('JXH1', 'JXF1') and FIRMfutures.EXPIRY_MONTH &amp;gt;= '01-Mar-2010' and CONTRACT in ('USFF/CBOT', 'AUIBCR/SFE') and FIRMfutures.STATUS = 'WHATIF']
8656: TStradeDB::retrieveTrades returned 0 trades
10152: 
10152: ################################################
8656: OUT ### PagefileUsage: 46,508 K, diff : 0 Bytes
10152: From xxxxxx@vxxxxxxxx 31 Mar 2010 11:33:24 (pid=3636,TSRW.52.2,ditTradeBookManager)
8656: OUT ### PeakPagefileUsage: 52,756 K, diff : 0 Bytes
10152: IN ### PagefileUsage: 46,508 K, PeakPagefileUsage: 52,756 K
10152: Fetch Trades For JSW
8656: Completed 31 Mar 2010 11:33:24 (0.031000s elapsed)
8656: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
10152: This user is GLOBAL hence executing the current Tradeserver Functionality 
10152:  with condition [BOOK in ('JXH1', 'JXF1') and TDtrade.EXPIRY &amp;gt;= '01-Mar-2010' and TDtrade.STATUS = 'WHATIF' and TDtrade.VERSION_DATE = '01-Mar-2010' and CONTRACT in ('NZBL/NZFE', 'AUBL/SFE') and FIRMfutures.STATUS = 'WHATIF']
8656: TStradeDB::retrieveTrades returned 0 trades
8656: OUT ### PagefileUsage: 46,508 K, diff : -68 K
8656: OUT ### PeakPagefileUsage: 52,756 K, diff : 0 Bytes
8656: Completed 31 Mar 2010 11:33:24 (0.032000s elapsed)
8656: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
&lt;/PRE&gt;

&lt;P&gt;So from the above I would get the following extracts:&lt;/P&gt;

&lt;PRE&gt;
8656: ################################################
8656: From xxxxxx@xxxxxxxx31 Mar 2010 11:33:24 (pid=2768,TSRW.52.2,ditTradeBookManager)
8656: IN ### PagefileUsage: 46,508 K, PeakPagefileUsage: 52,756 K
8656: Fetch Trades For FIRM
8656: This user is GLOBAL hence executing the current Tradeserver Functionality 
8656:  with condition [BOOK in ('JXH1', 'JXF1') and FIRMfutures.EXPIRY_MONTH &amp;gt;= '01-Mar-2010' and CONTRACT in ('USFF/CBOT', 'AUIBCR/SFE') and FIRMfutures.STATUS = 'WHATIF']
8656: TStradeDB::retrieveTrades returned 0 trades
8656: OUT ### PagefileUsage: 46,508 K, diff : 0 Bytes
8656: OUT ### PeakPagefileUsage: 52,756 K, diff : 0 Bytes
8656: Completed 31 Mar 2010 11:33:24 (0.031000s elapsed)
8656: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
&lt;/PRE&gt;

&lt;P&gt;AND&lt;/P&gt;

&lt;PRE&gt;
10152: ################################################
10152: From xxxxxxx@xxxxxxxx 31 Mar 2010 11:33:24 (pid=3636,TSRW.52.2,ditTradeBookManager)
10152: IN ### PagefileUsage: 46,508 K, PeakPagefileUsage: 52,756 K
10152: Fetch Trades For JSW
10152: This user is GLOBAL hence executing the current Tradeserver Functionality 
10152: TStradeDB::retrieveTrades returned 0 trades
10152: OUT ### PagefileUsage: 46,508 K, diff : 0 Bytes
10152: OUT ### PeakPagefileUsage: 52,756 K, diff : 0 Bytes
10152: Completed 31 Mar 2010 11:33:24 (0.000000s elapsed)
10152: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
&lt;/PRE&gt;

&lt;P&gt;AND&lt;/P&gt;

&lt;PRE&gt;
8656: ################################################
8656: From xxxxxxx@xxxxxxxxx 31 Mar 2010 11:33:24 (pid=2768,TSRW.52.2,ditTradeBookManager)
8656: IN ### PagefileUsage: 46,576 K, PeakPagefileUsage: 52,756 K
8656: Fetch Trades For FIRM
8656: This user is GLOBAL hence executing the current Tradeserver Functionality 
8656:  with condition [BOOK in ('JXH1', 'JXF1') and FIRMfutures.EXPIRY_MONTH &amp;gt;= '01-Mar-2010' and CONTRACT in ('NZBL/NZFE', 'AUBL/SFE') and FIRMfutures.STATUS = 'WHATIF']
8656: TStradeDB::retrieveTrades returned 0 trades
8656: OUT ### PagefileUsage: 46,508 K, diff : -68 K
8656: OUT ### PeakPagefileUsage: 52,756 K, diff : 0 Bytes
8656: Completed 31 Mar 2010 11:33:24 (0.032000s elapsed)
8656: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Apr 2010 17:55:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12268#M955</guid>
      <dc:creator>Josh</dc:creator>
      <dc:date>2010-04-26T17:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking unusual log files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12269#M956</link>
      <description>&lt;P&gt;Ok, so my first answer was way off, so I'm changing it.  Yes, that's allowed.&lt;/P&gt;

&lt;P&gt;I missed the slightly important fact that we're dealing with interleaved events here, as in event1 starts, writes a couple of lines, event2 starts, writes a couple of lines, event1 writes some more, event2 writes some more, event 1 completes then event 2 completes.&lt;/P&gt;

&lt;P&gt;Can Splunk re-order this so that events are separated and concatenated properly?  No it cannot, Splunk reads log files as they are written, it cannot be configured to re-order data.  However, it would be possible to write a scripted input to do this first, and then feed the data to Splunk.&lt;/P&gt;

&lt;P&gt;Alternatively, you could just index the data as single-line events and then use the 'stats' or 'transaction' commands to sort the various lines together in search output.&lt;/P&gt;

&lt;P&gt;The final option would be to change the way in which your processes write their log files.  Instead of one line at a time, is it possible to write a whole event at once so they are not intermingled?  Or even separate log-files would do the trick too.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2010 21:28:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12269#M956</guid>
      <dc:creator>Mick</dc:creator>
      <dc:date>2010-04-26T21:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking unusual log files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12270#M957</link>
      <description>&lt;P&gt;If you're stuck with this kinda cross-threaded indexing picture, you can still index everything as single line events and use the search language to put things back together at search time.  This often seems like a consolation prize but in many ways it can actually be a better and more flexible way to go.  For instance for a long running transaction you get the start events into the index and your system has the power to detect the problem before the transaction closes.  &lt;/P&gt;

&lt;P&gt;One concrete problem is that you end up with some weird things like half of 8656 is at its own starttime, and the other half is indexed at the starttime of 10152.  Therefore for any particular timerange you may need to filter out transactions whose end was clipped off, or else your statistics might get skewed slightly.  &lt;/P&gt;

&lt;P&gt;So to be able to account for that Im going to assume that there's some endEvent=1 field that we extract when we see the final line.  And Im also assuming that you are correctly extracting the 'eventId' field out of the single line events, and other fields involved are getting extracted properly.  &lt;/P&gt;

&lt;P&gt;So here are 2 ways to do it.  For both examples lets say you're interested in the peakPageFileUsage and elapsedTime fields &lt;/P&gt;

&lt;P&gt;1) the transaction command can put this back together with &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="foo" | transaction eventId maxspan=1m | search endEvent=1 | fields eventId peakPageFileUsage elapsedTime 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(the maxspan value you would use depends on how frequently the eventId's are reused by the system. )&lt;/P&gt;

&lt;P&gt;2) And stats is often overlooked but it can do a lot of this stuff just fine too. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="foo" | stats first(endEvent) first(peakPageFileUsage) first(elapsedTime) by eventId | search endEvent=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(and &lt;EM&gt;if&lt;/EM&gt; you ever have a field that appears multiple  times in a single eventId you could use the values() operator within stats and then operate on a multi-valued field from there. )&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2010 23:55:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12270#M957</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-04-26T23:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking unusual log files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12271#M958</link>
      <description>&lt;P&gt;What they said. Basically, you either use &lt;CODE&gt;transaction&lt;/CODE&gt; after the fact, or you fix how you log by writing log entries atomically.&lt;/P&gt;

&lt;P&gt;There is a rather exotic possibility also of using &lt;CODE&gt;transaction&lt;/CODE&gt; and then writing the results to a summary index, but this requires a little extra work and customization.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2010 00:05:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12271#M958</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-04-27T00:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking unusual log files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12272#M959</link>
      <description>&lt;P&gt;I have one alternate suggestion for example 1 that is less time-range sensitive.  Assuming your start and end markers are as clear-cut as they were stated, then you may want to try the transaction command:   &lt;CODE&gt;transaction eventId startswith="################################################" endswith="@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"&lt;/CODE&gt;  Then you don't need the &lt;CODE&gt;| search endEvent=1&lt;/CODE&gt; part.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2010 00:22:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12272#M959</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-27T00:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking unusual log files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12273#M960</link>
      <description>&lt;P&gt;If you haven't done so already, I would suggest explicitly add a &lt;CODE&gt;TIME_FORMAT&lt;/CODE&gt; in your &lt;CODE&gt;props.conf&lt;/CODE&gt; file.  (Maybe even &lt;CODE&gt;TIME_PREFIX&lt;/CODE&gt; too.)  You don't want splunk guessing timestamps formats and trying to turn your &lt;CODE&gt;eventId&lt;/CODE&gt; field into a date/time.  You also have dates following the term &lt;CODE&gt;EXPIRY_MONTH&lt;/CODE&gt; that could be picked up as well, so you probably want to nail this down and keep splunk from guessing.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2010 03:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Breaking-unusual-log-files/m-p/12273#M960</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-27T03:21:43Z</dc:date>
    </item>
  </channel>
</rss>

