<?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: Multistep transaction using stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497262#M138507</link>
    <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;there are many ways to achieve this, and to understand the best one, more information regarding your data is required. in the answer i also assumed you have teh &lt;CODE&gt;key&lt;/CODE&gt; in each line / event.&lt;BR /&gt;
below is one option that might meets your need, run it anywhere.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1 
| eval data = "5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferInitiationCompleted 2019-12-03T13:15:04.283Z;;;5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferSettled 2019-12-03T13:15:04.275Z;;;5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferInitiationProcessed 2019-12-03T13:15:03.820Z;;;5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferInitiationReceived 2019-12-03T13:15:03.764Z"
| makemv delim=";;;" data
| mvexpand data
| rex field=data "(?&amp;lt;key&amp;gt;[^\s]+)\s+(?&amp;lt;EventCode&amp;gt;[^\s]+)\s+(?&amp;lt;time&amp;gt;.*+)"
| table time key EventCode
| rename COMMENT as "the above generates data below is the solution" 
| eval time_epoch = strptime(time, "%Y-%m-%dT%H:%M:%S.%3N")
| sort time_epoch
| streamstats range(time_epoch) as trans_duration by key
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
    <pubDate>Thu, 05 Dec 2019 12:29:59 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2019-12-05T12:29:59Z</dc:date>
    <item>
      <title>Multistep transaction using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497261#M138506</link>
      <description>&lt;P&gt;Hi, I have following stats table &lt;BR /&gt;
key                                              EventCode                                                        timestamp&lt;BR /&gt;
5q9ptD2QRZGkIrv1hPD3Mg   customerCreditTransferInitiationCompleted   2019-12-03T13:15:04.283Z&lt;BR /&gt;
                                                     customerCreditTransferSettled                          2019-12-03T13:15:04.275Z&lt;BR /&gt;
                                                     customerCreditTransferInitiationProcessed    2019-12-03T13:15:03.820Z&lt;BR /&gt;
                                                     customerCreditTransferInitiationReceived      2019-12-03T13:15:03.764Z&lt;/P&gt;

&lt;P&gt;I would like to measure duration of each step. any ideas how to do it?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 10:41:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497261#M138506</guid>
      <dc:creator>knarinen3</dc:creator>
      <dc:date>2019-12-05T10:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Multistep transaction using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497262#M138507</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;there are many ways to achieve this, and to understand the best one, more information regarding your data is required. in the answer i also assumed you have teh &lt;CODE&gt;key&lt;/CODE&gt; in each line / event.&lt;BR /&gt;
below is one option that might meets your need, run it anywhere.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1 
| eval data = "5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferInitiationCompleted 2019-12-03T13:15:04.283Z;;;5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferSettled 2019-12-03T13:15:04.275Z;;;5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferInitiationProcessed 2019-12-03T13:15:03.820Z;;;5q9ptD2QRZGkIrv1hPD3Mg customerCreditTransferInitiationReceived 2019-12-03T13:15:03.764Z"
| makemv delim=";;;" data
| mvexpand data
| rex field=data "(?&amp;lt;key&amp;gt;[^\s]+)\s+(?&amp;lt;EventCode&amp;gt;[^\s]+)\s+(?&amp;lt;time&amp;gt;.*+)"
| table time key EventCode
| rename COMMENT as "the above generates data below is the solution" 
| eval time_epoch = strptime(time, "%Y-%m-%dT%H:%M:%S.%3N")
| sort time_epoch
| streamstats range(time_epoch) as trans_duration by key
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 12:29:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497262#M138507</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-12-05T12:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multistep transaction using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497263#M138508</link>
      <description>&lt;P&gt;hi, the data provided was in stats format. &lt;BR /&gt;
the raw data is like this: &lt;BR /&gt;
{"container_name":"/beconsumer_KafkaConsumer.1.irz785be5dhsco32lqqtu51bh","source":"stdout","log":"2019-12-03 18:05:00 INFO  EventLogger:%_ - Topic: cctiBusinessEvents-Nft01X, Key: 5q9ptD2QRZGkIrv1hPD3Mg, transactionTraceIdentification=ade1c48f-b51f-4b5c-8f17-ae1adcba15f4, paymentProduct=DEPFUND, entityId=f8b15f9d-44e8-48d2-b74b-a6c10c14682a, amount=1, eventCode=customerCreditTransferInitiationCompleted, channel=retail, Offset=226816, currency=DKK, businessEventId=POM-CustomerCreditTransferInitiationV07-2-1782729, instructionReceiptIdentification=PMTDKRG1239297, Partition=1, dateTime=2019-12-03T13:15:04.283Z","container_id":"0172589e4fab1e910305476a8090b66a0d0e5ce6fd8e076e99d51f333d9c45c4"}&lt;/P&gt;

&lt;P&gt;{"source":"stdout","log":"2019-12-03 18:05:00 INFO  EventLogger:%_ - Topic: cctiBusinessEvents-Nft01X, Key: 5q9ptD2QRZGkIrv1hPD3Mg, entityId=f8b15f9d-44e8-48d2-b74b-a6c10c14682a, eventCode=customerCreditTransferSettled, channel=retail, Offset=226815, businessEventId=POM-CustomerCreditTransferInitiationV07-2-1782726, instructionReceiptIdentification=65052\"}, Partition=1, dateTime=2019-12-03T13:15:04.275Z","container_id":"0172589e4fab1e910305476a8090b66a0d0e5ce6fd8e076e99d51f333d9c45c4","container_name":"/beconsumer_KafkaConsumer.1.irz785be5dhsco32lqqtu51bh"}&lt;/P&gt;

&lt;P&gt;{"container_id":"0172589e4fab1e910305476a8090b66a0d0e5ce6fd8e076e99d51f333d9c45c4","container_name":"/beconsumer_KafkaConsumer.1.irz785be5dhsco32lqqtu51bh","source":"stdout","log":"2019-12-03 18:05:00 INFO  EventLogger:%_ - Topic: cctiBusinessEvents-Nft01X, Key: 5q9ptD2QRZGkIrv1hPD3Mg, entityId=f8b15f9d-44e8-48d2-b74b-a6c10c14682a, eventCode=customerCreditTransferInitiationProcessed, channel=retail, Offset=226813, businessEventId=POM-CustomerCreditTransferInitiationV07-2-1782725, instructionReceiptIdentification=65052\"}, Partition=1, dateTime=2019-12-03T13:15:03.820Z"}&lt;/P&gt;

&lt;P&gt;{"container_name":"/beconsumer_KafkaConsumer.1.irz785be5dhsco32lqqtu51bh","source":"stdout","log":"2019-12-03 18:05:00 INFO  EventLogger:%_ - Topic: cctiBusinessEvents-Nft01X, Key: 5q9ptD2QRZGkIrv1hPD3Mg, transactionTraceIdentification=ade1c48f-b51f-4b5c-8f17-ae1adcba15f4, paymentProduct=DEPFUND, entityId=f8b15f9d-44e8-48d2-b74b-a6c10c14682a, amount=1, eventCode=customerCreditTransferInitiationReceived, channel=retail, Offset=226812, currency=DKK, businessEventId=POM-CustomerCreditTransferInitiationV07-2-1782709, instructionReceiptIdentification=PMTDKRG1239297, Partition=1, dateTime=2019-12-03T13:15:03.764Z","container_id":"0172589e4fab1e910305476a8090b66a0d0e5ce6fd8e076e99d51f333d9c45c4"}&lt;/P&gt;

&lt;P&gt;and query I use to format it:&lt;BR /&gt;
search query &lt;BR /&gt;
| rex "Topic:\s+(?.&lt;EM&gt;?),\s+Key:\s+(?.&lt;/EM&gt;?),"&lt;BR /&gt;
| rex "entityId=(?\S+?),"&lt;BR /&gt;
| rex "eventCode=(?\S+?),"&lt;BR /&gt;
| rex "Partition=(?\S+?)"&lt;BR /&gt;
| rex "dateTime=(?\S+?)\""&lt;BR /&gt;
|stats values(topic) as Topic values(entityId) as EntityId  list(eventCode) as EventCode list(dateTime) as timestamp by key&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:11:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multistep-transaction-using-stats/m-p/497263#M138508</guid>
      <dc:creator>knarinen3</dc:creator>
      <dc:date>2020-09-30T03:11:35Z</dc:date>
    </item>
  </channel>
</rss>

