<?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 to merge two message threads into one? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611688#M212660</link>
    <description>&lt;P&gt;Something like this? (The first eval wouldn't be necessary if mainsys and backupsys gives difference source or some easily identifiable field.)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval source = if(len('fields.Mainsys_srcMsgId')==0 OR isnull('fields.Mainsys_srcMsgId'), "mainsys", "backupsys")
| eval SrcMsgId = if(source == "mainsys", 'fields.srcMsgId', 'fields.Mainsys_srcMsgId')
| reverse
| transaction maxevents=5 source
| eval SrcMsgIds = mvjoin(SrcMsgId, "+")
| stats list(_time) as _time list(eval('fields.srcMsgId')) as "fields.srcMsgId" list(eval('fields.Mainsys_srcMsgId')) as "fields.Mainsys_srcMsgId" by SrcMsgIds&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Sep 2022 22:43:15 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-09-01T22:43:15Z</dc:date>
    <item>
      <title>How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611498#M212605</link>
      <description>&lt;P&gt;I have two message threads, each thread consists of ten messages.&amp;nbsp;I need to request to display these two chains in one.&lt;BR /&gt;&lt;SPAN&gt;The new thread must consist of ten different messages: five messages from one system, five messages from another (backup) system.&amp;nbsp;Messages from the system use the same SrcMsgId value. Each system has a unique SrcMsgId within the same chain.&amp;nbsp;The message chain from the backup system enters the splunk immediately after the messages from the main system.&amp;nbsp;Messages from the standby system also have a Mainsys_srcMsgId value - this value is identical to the main system's SrcMsgId value. Tell me how can I display a chain of all ten messages? Perhaps first messages from the first system (main), then from the second (backup) with the display of the time of arrival at the server.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Specifically, we want to see all ten messages one after the other, in the order in which they arrived at the server.&amp;nbsp;Five messages from the primary, for example: ("srcMsgId": "rwfsdfsfqwe121432gsgsfgd71") and five from the backup: ("srcMsgId": "rwfsdfsfqwe121432gsgsfgd72").&amp;nbsp;The problem is that messages from other systems also come to the server, all messages are mixed (chaotically), which is why we want to organize all messages from one system and its relative in the search.&amp;nbsp;Messages from the backup system are associated with the main system only by this parameter: "Mainsys_srcMsgId" - using this key, we understand that messages come from the backup system (secondary to the main one).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Examples of messages from the primary and secondary system:&lt;/P&gt;
&lt;P&gt;Main system:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"event": "Sourcetype test please",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"sourcetype": "testsystem-2",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"host": "some-host-123",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"fields":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"messageId": "ED280816-E404-444A-A2D9-FFD2D171F32",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"srcMsgId": "rwfsdfsfqwe121432gsgsfgd71",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"Mainsys_srcMsgId": "",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"baseSystemId": "abc1",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"routeInstanceId": "abc2",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"routepointID": "abc3",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"eventTime": "1985-04-12T23:20:50Z",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"messageType": "abc4",&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;..........................................................................................&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Message from backup system:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{&lt;BR /&gt;"event": "Sourcetype test please",&lt;BR /&gt;"sourcetype": "testsystem-2",&lt;BR /&gt;"host": "some-host-123",&lt;BR /&gt;"fields":&lt;BR /&gt;{&lt;BR /&gt;"messageId": "ED280816-E404-444A-A2D9-FFD2D171F23",&lt;BR /&gt;"srcMsgId": "rwfsdfsfqwe121432gsgsfgd72",&lt;BR /&gt;"Mainsys_srcMsgId": "rwfsdfsfqwe121432gsgsfgd71",&lt;BR /&gt;"baseSystemId": "abc1",&lt;BR /&gt;"routeInstanceId": "abc2",&lt;BR /&gt;"routepointID": "abc3",&lt;BR /&gt;"eventTime": "1985-04-12T23:20:50Z",&lt;BR /&gt;"messageType": "abc4",&lt;BR /&gt;"GISGMPRequestID": "PS000BA780816-E404-444A-A2D9-FFD2D1712345",&lt;BR /&gt;"GISGMPResponseID": "PS000BA780816-E404-444B-A2D9-FFD2D1712345",&lt;BR /&gt;"resultcode": "abc7",&lt;BR /&gt;"resultdesc": "abc8"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When we want to combine in a query only five messages from one chain, related: "srcMsgId".&lt;BR /&gt;We make the following request:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT&gt;index="bl_logging" sourcetype="testsystem-2"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT&gt;|&amp;nbsp;транзакция maxpause=5m srcMsgId Mainsys_srcMsgId messageId&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT&gt;|&amp;nbsp;таблица _time srcMsgId Mainsys_srcMsgId messageId продолжительность eventcount&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT&gt;|&amp;nbsp;сортировать srcMsgId_time&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT&gt;|&amp;nbsp;streamstats current=f window=1 значения (_time) as prevTime по теме&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT&gt;|&amp;nbsp;eval timeDiff=_time-prevTime&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT&gt;|&amp;nbsp;delta _time как timediff&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 19:18:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611498#M212605</guid>
      <dc:creator>metylkinandrey</dc:creator>
      <dc:date>2022-08-31T19:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611548#M212624</link>
      <description>&lt;P&gt;The key to this is to establish a field that represents the link between the main system and the backup system. &amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval SrcMsgId = if(len('fields.Mainsys_srcMsgId')==0 OR isnull('fields.Mainsys_srcMsgId'), 'fields.srcMsgId', 'fields.Mainsys_srcMsgId')&lt;/LI-CODE&gt;&lt;P&gt;Then, if you want to use transaction, perform transaction on this field, e.g.,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval SrcMsgId = if(len('fields.Mainsys_srcMsgId')==0, 'fields.srcMsgId', 'fields.Mainsys_srcMsgId')
| transaction maxpause=5m SrcMsgId fields.eventTime&lt;/LI-CODE&gt;&lt;P&gt;You can also use stats on this field, which is less expensive than transaction.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 07:15:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611548#M212624</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-01T07:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611598#M212629</link>
      <description>&lt;P&gt;It actually works, but it's not quite what I need, apparently I explained it wrong.&lt;BR /&gt;It so happened that the first or second messages from two threads are displayed together:&lt;BR /&gt;rwfsdfsfqwe121432gsgsfgd100&lt;BR /&gt;rwfsdfsfqwe121432gsgsfgd20&lt;/P&gt;&lt;P&gt;I need something a little different, I need to somehow sort the entire list of incoming messages so that six messages from the main system are displayed first, then from the backup system and I can see the interval between letters (between the first and second, second and third) and so on until tenth message.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 12:08:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611598#M212629</guid>
      <dc:creator>metylkinandrey</dc:creator>
      <dc:date>2022-09-01T12:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611607#M212631</link>
      <description>&lt;P&gt;In a word, you need what is in the screenshot, but without using paint))&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 12:46:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611607#M212631</guid>
      <dc:creator>metylkinandrey</dc:creator>
      <dc:date>2022-09-01T12:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611688#M212660</link>
      <description>&lt;P&gt;Something like this? (The first eval wouldn't be necessary if mainsys and backupsys gives difference source or some easily identifiable field.)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval source = if(len('fields.Mainsys_srcMsgId')==0 OR isnull('fields.Mainsys_srcMsgId'), "mainsys", "backupsys")
| eval SrcMsgId = if(source == "mainsys", 'fields.srcMsgId', 'fields.Mainsys_srcMsgId')
| reverse
| transaction maxevents=5 source
| eval SrcMsgIds = mvjoin(SrcMsgId, "+")
| stats list(_time) as _time list(eval('fields.srcMsgId')) as "fields.srcMsgId" list(eval('fields.Mainsys_srcMsgId')) as "fields.Mainsys_srcMsgId" by SrcMsgIds&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 22:43:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611688#M212660</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-09-01T22:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611720#M212670</link>
      <description>&lt;P&gt;Thank you very much! You helped a lot!&lt;BR /&gt;This request did not work for me directly, but it turned out differently for me. I took most of the lines from your request and substituted in my previous one. And it seems to work as we need. I'll test it and send my version of the request.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 09:52:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/611720#M212670</guid>
      <dc:creator>metylkinandrey</dc:creator>
      <dc:date>2022-09-02T09:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge two message threads into one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/612219#M212858</link>
      <description>&lt;P&gt;We have created two types of requests that work:&lt;/P&gt;&lt;P&gt;index="main"&lt;BR /&gt;| append [ search sourcetype=testsystem-reverse | eval chain=coalesce(Mainsys_srcMsgId,srcMsgId) ]&lt;BR /&gt;| append [ search sourcetype=testsystem-main | eval chain=coalesce(srcMsgId,Mainsys_srcMsgId) ]&lt;BR /&gt;| transaction maxpause=5m srcMsgId Mainsys_srcMsgId messageId chain&lt;BR /&gt;| table _time srcMsgId Mainsys_srcMsgId messageId duration eventcount chain&lt;BR /&gt;| sort chain _time&lt;BR /&gt;| streamstats current=f window=1 values(_time) as prevTime by subject&lt;BR /&gt;| eval timeDiff=_time-prevTime&lt;BR /&gt;| delta _time as timediff&lt;/P&gt;&lt;P&gt;And&lt;/P&gt;&lt;P&gt;index="main"&lt;BR /&gt;| eval CONNECTIG_ID=if(len('Mainsys_srcMsgId')==0 OR isnull('Mainsys_srcMsgId'),'srcMsgId','Mainsys_srcMsgId')&lt;BR /&gt;| stats list(routepointID) as routepoint list(srcMsgId) as srcMsgId list(Mainsys_srcMsgId) as Mainsys_srcMsgId list(eventTime) as eventTime by CONNECTIG_ID&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 08:51:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-message-threads-into-one/m-p/612219#M212858</guid>
      <dc:creator>metylkinandrey</dc:creator>
      <dc:date>2022-09-07T08:51:09Z</dc:date>
    </item>
  </channel>
</rss>

