<?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: Join two lines in the same search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494302#M137808</link>
    <description>&lt;P&gt;I gave you a complete answer already.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Dec 2019 15:35:25 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-12-05T15:35:25Z</dc:date>
    <item>
      <title>Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494293#M137799</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I'm currently monitoring log files. &lt;BR /&gt;
I have exctrated 2 fields end_collection_timestamp &amp;amp; starting_collection_timestamp. &lt;/P&gt;

&lt;P&gt;I want to calculate duration of execution. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval duration = end_collection_timestamp - starting_collection_timestamp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this method do not work because every lines with field end_collection_timestamp do not contain the fields starting_collection_timestamp. &lt;/P&gt;

&lt;P&gt;I do not understand all but i think this is the root cause. &lt;/P&gt;

&lt;P&gt;The result i want is a timechart with avg duration by day &amp;amp; source.&lt;/P&gt;

&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:08:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494293#M137799</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2020-09-30T03:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494294#M137800</link>
      <description>&lt;P&gt;I would guess you have some kind of id field for which you are calculating your duration, if yes, you need to first bring them to the same row. One way to do this is like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats max(end_collection_timestamp ) as end_collection_timestamp , min(starting_collection_timestamp) as starting_collection_timestamp by &amp;lt;your id field&amp;gt;
| eval duration = end_collection_timestamp - starting_collection_timestamp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is just one of the solutions. If this is not what you were looking for, please elaborate on the question by adding some sample data.&lt;/P&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494294#M137800</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-11-27T13:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494295#M137801</link>
      <description>&lt;P&gt;Hi @arjunpkishore5, &lt;/P&gt;

&lt;P&gt;Thank you for your help. &lt;/P&gt;

&lt;P&gt;i tried this search but the field duration is empty. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="saplogs" sourcetype=SAPCARBOOKING source="CARBOOKING.*.log" 
| stats max(end_collection_timestamp) as end_collection_timestamp , min(starting_collection_timestamp) as starting_collection_timestamp by source 
| eval duration = end_collection_timestamp - starting_collection_timestamp 
| table duration, starting_collection_timestamp, end_collection_timestamp, source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 13:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494295#M137801</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2019-11-27T13:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494296#M137802</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/163695"&gt;@clementros&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;Are the fields end_collection_timestamp and end_collection_timestamp stored as a string or epoch?&lt;BR /&gt;
If it is a string, you have to first use strptime to convert it to epoch before the stats like this. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="saplogs" sourcetype=SAPCARBOOKING source="CARBOOKING.*.log" 
| eval end_collection_timestamp= strptime(end_collection_timestamp, "&amp;lt;time format&amp;gt;")
| eval starting_collection_timestamp= strptime(starting_collection_timestamp, "&amp;lt;time format&amp;gt;")
| stats max(end_collection_timestamp) as end_collection_timestamp , min(starting_collection_timestamp) as starting_collection_timestamp by source 
| eval duration = end_collection_timestamp - starting_collection_timestamp 
| table duration, starting_collection_timestamp, end_collection_timestamp, source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the documentation for strptime - &lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/DateandTimeFunctions#strptime.28X.2CY.29" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.0/SearchReference/DateandTimeFunctions#strptime.28X.2CY.29&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:09:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494296#M137802</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2020-09-30T03:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494297#M137803</link>
      <description>&lt;P&gt;They are store like string. &lt;/P&gt;

&lt;P&gt;I updated your search like this : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;strptime(end_collection_timestamp, "%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But still have no value for &lt;STRONG&gt;end_collection_timestamp, starting_collection_timestamp, duration&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:09:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494297#M137803</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2020-09-30T03:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494298#M137804</link>
      <description>&lt;P&gt;can you post a sample of the timestamp in it's string format&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 16:57:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494298#M137804</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2019-11-27T16:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494299#M137805</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | streamstats count(end_collection_timestamp) AS sessionID BY source
| stats min(starting_collection_timestamp) AS _time max(end_collection_timestamp) AS end_collection_timestamp BY sessionID source
| eval duration = end_collection_timestamp - _time
| timechart span=1d avg(duration) BY source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 17:40:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494299#M137805</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-27T17:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494300#M137806</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval t=typeof(starting_collection_timestamp)
            _time                      |             t
2019-11-29 08:56:43                 Invalid

| makeresults | eval t=typeof(end_collection_timestamp)

            _time                      |             t
2019-11-29 08:56:43                 Invalid
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2019 07:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494300#M137806</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2019-11-29T07:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494301#M137807</link>
      <description>&lt;P&gt;starting_collection_timestamp = Thu Oct 17 22:40:10 GMT 2019&lt;BR /&gt;
end_collection_timestamp = Thu Oct 17 22:40:21 GMT 2019&lt;/P&gt;

&lt;P&gt;please help&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:15:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494301#M137807</guid>
      <dc:creator>clementros</dc:creator>
      <dc:date>2020-09-30T03:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Join two lines in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494302#M137808</link>
      <description>&lt;P&gt;I gave you a complete answer already.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 15:35:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-two-lines-in-the-same-search/m-p/494302#M137808</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-05T15:35:25Z</dc:date>
    </item>
  </channel>
</rss>

