<?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: Splunk transaction  – Trouble extracting first and last messages in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745468#M241449</link>
    <description>&lt;P&gt;Not sure that's what you expect, let me know if you need something else, here are two raw events that my query matched together, but response is not being displayed (while present in the output _raw)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;{"severity":"INFO","logger":"com.PayloadLogger","thread":"40362833","message":"RECEIVER[20084732]: POST /my-end-point Headers: {sedatimeout=[60000], x-forwarded-port=[443], jmsexpiration=[0], host=[hostname], content-type=[application/json], Content-Length=[1461], sending.interface=[ANY], Accept=[application/json], cookie=[....], x-forwarded-proto=[https]} {{\"content\":"Any content here"}}","properties":{"environment":"any","transactionOriginator":"any","customerId":"any","correlationId":"any","configurationId":"any"}}&lt;/P&gt;&lt;P&gt;{"severity":"INFO","logger":"com.PayloadLogger","thread":"40362833","message":"SENDER[20084732]: Status: {200} Headers: {Date=[Mon, 05 May 2025 07:27:18 GMT], Content-Type=[application/json]} {{\"generalProcessingStatus\":\"OK\",\"content\":[]}}","properties":{"environment":"any","transactionOriginator":"any","customerId":"any","correlationId":"any","configurationId":"any}}&lt;BR /&gt;&lt;BR /&gt;I've been trying to use stats as well but have more trouble than with the transaction, which works pretty well (despite this missing response field). Can't say im a splunk expert&lt;/P&gt;</description>
    <pubDate>Mon, 05 May 2025 07:58:39 GMT</pubDate>
    <dc:creator>Jessydan</dc:creator>
    <dc:date>2025-05-05T07:58:39Z</dc:date>
    <item>
      <title>Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745464#M241446</link>
      <description>&lt;P class=""&gt;Hello,&lt;/P&gt;&lt;P class=""&gt;I'm working on a Splunk query to track REST calls in our logs. Specifically, I’m trying to use the transaction command to group related logs — each transaction should include exactly two messages: a &lt;STRONG&gt;RECEIVER&lt;/STRONG&gt; log and a &lt;STRONG&gt;SENDER&lt;/STRONG&gt; log.&lt;/P&gt;&lt;P class=""&gt;Here’s my current query:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=...
("SENDER[" OR ("RECEIVER[" AND "POST /my-end-point*"))
| rex "\[(?&amp;lt;id&amp;gt;\d+)\]"
| transaction id startswith="RECEIVER" endswith="SENDER" mvlist=message
| search eventcount &amp;gt; 1
| eval count=mvcount(message)
| eval request=mvindex(message, 0)
| eval response=mvindex(message, 1)
| table id, duration, count, request, response, _raw&lt;/LI-CODE&gt;&lt;P class=""&gt;&lt;BR /&gt;The idea is to group together RECEIVER and SENDER logs using the transaction id that my logs creates (e.g., RECEIVER[52] and SENDER[52]), and then extract and separate the &lt;STRONG&gt;first&lt;/STRONG&gt; and &lt;STRONG&gt;second&lt;/STRONG&gt; messages of the transaction into request and response to have a better visualisation.&lt;/P&gt;&lt;P class=""&gt;The transaction command seems to be grouping the logs correctly, I get the right number of transactions, and both receiver and sender logs are present in the _raw&amp;nbsp;field.&lt;/P&gt;&lt;P class=""&gt;For a few cases it works fine, I have as expected the proper request and response in two distinct fields, but for many transactions, the response (second message) is showing as NULL, even though eventcount is 2 and both messages are visible in _raw&lt;/P&gt;&lt;P&gt;The&amp;nbsp;message&amp;nbsp;field is well present in both ends of the transaction, as I can see it in the _raw output.&lt;FONT face="Menlo, Monaco, Consolas, Courier New, monospace" color="#c7254e"&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;Can someone guide me on what is wrong with my query ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 07:22:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745464#M241446</guid>
      <dc:creator>Jessydan</dc:creator>
      <dc:date>2025-05-05T07:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745466#M241448</link>
      <description>&lt;P&gt;Please provide some sample data (anonymised) which demonstrate your issue&lt;/P&gt;&lt;P&gt;Having said that, you could try using stats to gather your events by id as this is can be more deterministic than transaction&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 07:45:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745466#M241448</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-05-05T07:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745468#M241449</link>
      <description>&lt;P&gt;Not sure that's what you expect, let me know if you need something else, here are two raw events that my query matched together, but response is not being displayed (while present in the output _raw)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;{"severity":"INFO","logger":"com.PayloadLogger","thread":"40362833","message":"RECEIVER[20084732]: POST /my-end-point Headers: {sedatimeout=[60000], x-forwarded-port=[443], jmsexpiration=[0], host=[hostname], content-type=[application/json], Content-Length=[1461], sending.interface=[ANY], Accept=[application/json], cookie=[....], x-forwarded-proto=[https]} {{\"content\":"Any content here"}}","properties":{"environment":"any","transactionOriginator":"any","customerId":"any","correlationId":"any","configurationId":"any"}}&lt;/P&gt;&lt;P&gt;{"severity":"INFO","logger":"com.PayloadLogger","thread":"40362833","message":"SENDER[20084732]: Status: {200} Headers: {Date=[Mon, 05 May 2025 07:27:18 GMT], Content-Type=[application/json]} {{\"generalProcessingStatus\":\"OK\",\"content\":[]}}","properties":{"environment":"any","transactionOriginator":"any","customerId":"any","correlationId":"any","configurationId":"any}}&lt;BR /&gt;&lt;BR /&gt;I've been trying to use stats as well but have more trouble than with the transaction, which works pretty well (despite this missing response field). Can't say im a splunk expert&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 07:58:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745468#M241449</guid>
      <dc:creator>Jessydan</dc:creator>
      <dc:date>2025-05-05T07:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745470#M241451</link>
      <description>&lt;P&gt;transaction can silently ignore data, depending on data volume, time between start and end and you will not get any indication that data has been discarded.&lt;/P&gt;&lt;P&gt;It's far better to use stats to group by id - which you appear to have.&lt;/P&gt;&lt;P&gt;At the simplest level you can replace transaction with stats like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=...
("SENDER[" OR ("RECEIVER[" AND "POST /my-end-point*"))
| rex "\[(?&amp;lt;id&amp;gt;\d+)\]"
| stats list(_raw) as _raw list(message) as message min(_time) as start_time max(_time) as end_time by id
| eval duration=end_time - start_time, eventcount=mvcount(_raw)
| eval request=mvindex(message, 0)
| eval response=mvindex(message, 1)
| table id, duration, count, request, response, _raw&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 08:05:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745470#M241451</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-05-05T08:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745471#M241452</link>
      <description>&lt;P&gt;It's hard to say what's "wrong" not knowing your data but while transaction can be sometimes useful (in some strange use cases) it's often easier, and faster to simply use stats. Mostly because transaction has loads of limitations that stats don't have.&lt;/P&gt;&lt;P&gt;Quick glance at your search suggests that for some reason the &lt;EM&gt;message&lt;/EM&gt; field is not extracted properly from your event so you're not getting two separate values in your multivalued&amp;nbsp;&lt;EM&gt;message&lt;/EM&gt; output field.&lt;/P&gt;&lt;P&gt;As I said I'd go with&lt;/P&gt;&lt;PRE&gt;index=...&lt;BR /&gt;("SENDER[" OR ("RECEIVER[" AND "POST /my-end-point*"))&lt;BR /&gt;| rex "\[(?&amp;lt;id&amp;gt;\d+)\]"&lt;BR /&gt;| eval request=if(searchmatch("SENDER[",message,null())&lt;BR /&gt;| eval response=if(searchmatch("\"RECEIVER[\" AND \"POST /my-end-point*\"",message,null())&lt;BR /&gt;| stats range(_time) as duration, count, values(request) as request, values(response) as response, values(_raw) as _raw by id&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 08:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745471#M241452</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-05-05T08:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745473#M241454</link>
      <description>&lt;P&gt;I'm a bit puzzled now, while both of the queries you proposed me are working, they raise the same issue.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;With this one I get the expected output, but with way less transactions than expected (like 10 instead of 100)&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;("SENDER[" OR ("RECEIVER[" AND "POST /my-end-point*"))
| rex "\[(?&amp;lt;id&amp;gt;\d+)\]"
| stats list(_raw) as _raw list(message) as message min(_time) as start_time max(_time) as end_time by id
| eval duration=end_time - start_time, eventcount=mvcount(_raw)
| eval request=mvindex(message, 0)
| eval response=mvindex(message, 1)
| table id, duration, count, request, response, _raw&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;And with this one, I have the same issue where _raw contains the response, but I don't get it in the response field, it is properly present for only around 10% of the transactions&lt;/P&gt;&lt;PRE&gt;index=...&lt;BR /&gt;("SENDER[" OR ("RECEIVER[" AND "POST /my-end-point*"))&lt;BR /&gt;| rex "\[(?&amp;lt;id&amp;gt;\d+)\]"&lt;BR /&gt;| eval request=if(searchmatch("SENDER[",message,null())&lt;BR /&gt;| eval response=if(searchmatch("\"RECEIVER[\" AND \"POST /my-end-point*\"",message,null())&lt;BR /&gt;| stats range(_time) as duration, count, values(request) as request, values(response) as response, values(_raw) as _raw by id&lt;BR /&gt;| where isnotnull(request)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 08:34:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745473#M241454</guid>
      <dc:creator>Jessydan</dc:creator>
      <dc:date>2025-05-05T08:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745474#M241455</link>
      <description>&lt;P&gt;Apparently you have problems with proper extraction of the &lt;EM&gt;message&lt;/EM&gt; field. So you should verify your data onboarding and start with fixing the extractions.&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 08:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745474#M241455</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-05-05T08:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745478#M241457</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/309829"&gt;@Jessydan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couldnt agree more with the others regarding stats - it seems you're having issues extracting your message/ID in these examples though - does the following work for you? I used your provided sample data in the below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="livehybrid_0-1746437628236.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/38850i7A1E99A60A81C182/image-size/medium?v=v2&amp;amp;px=400" role="button" title="livehybrid_0-1746437628236.png" alt="livehybrid_0-1746437628236.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| windbag | head 2
| streamstats count as row_number
| eval _raw=if(row_number==1, "{\"severity\":\"INFO\",\"logger\":\"com.PayloadLogger\",\"thread\":\"40362833\",\"message\":\"RECEIVER[20084732]: POST /my-end-point Headers: {sedatimeout=[60000], x-forwarded-port=[443], jmsexpiration=[0], host=[hostname], content-type=[application/json], Content-Length=[1461], sending.interface=[ANY], Accept=[application/json], cookie=[....], x-forwarded-proto=[https]} {{\\\"content\\\":\\\"Any content here\\\"}}\",\"properties\":{\"environment\":\"any\",\"transactionOriginator\":\"any\",\"customerId\":\"any\",\"correlationId\":\"any\",\"configurationId\":\"any\"}}", "{\"severity\":\"INFO\",\"logger\":\"com.PayloadLogger\",\"thread\":\"40362833\",\"message\":\"SENDER[20084732]: Status: {200} Headers: {Date=[Mon, 05 May 2025 07:27:18 GMT], Content-Type=[application/json]} {{\\\"generalProcessingStatus\\\":\\\"OK\\\",\\\"content\\\":[]}}\",\"properties\":{\"environment\":\"any\",\"transactionOriginator\":\"any\",\"customerId\":\"any\",\"correlationId\":\"any\",\"configurationId\":\"any\"}}") 
| spath input=_raw
| rex field=message "^(?&amp;lt;msgType&amp;gt;[A-Z]+)\[(?&amp;lt;id&amp;gt;[0-9]+)\].*"
| stats range(_time) as duration, count, values(msgType) as msgType by id
| where isnotnull(msgType) AND msgType="RECEIVER" AND msgType="SENDER"&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":glowing_star:"&gt;🌟&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Did this answer help you?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;If so, please consider:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Adding karma to show it was useful&lt;/LI&gt;&lt;LI&gt;Marking it as the solution if it resolved your issue&lt;/LI&gt;&lt;LI&gt;Commenting if you need any clarification&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Your feedback encourages the volunteers in this community to continue contributing&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 09:33:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745478#M241457</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-05-05T09:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745482#M241458</link>
      <description>&lt;P&gt;Just heads up, it was indeed an issue with the extraction of the fields, my event are so big that splunk stops extracting fields at some point. Thanks all for the help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 11:08:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745482#M241458</guid>
      <dc:creator>Jessydan</dc:creator>
      <dc:date>2025-05-05T11:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745530#M241475</link>
      <description>&lt;P&gt;Is your data JSON?&lt;/P&gt;&lt;P&gt;If so, Splunk will only extract the first 5K of the JSON object in an event. I'm not totally sure if it has that 5k limit for other auto kv field extraction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 23:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745530#M241475</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2025-05-05T23:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk transaction  – Trouble extracting first and last messages</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745534#M241478</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;diagnoses, default field extraction stops at 50K. &amp;nbsp;You can change this in limits.conf. &amp;nbsp;The stanza is [kv], property name is&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;maxchars&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I recommend that you fix another problem&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;hinted at: You should extract &lt;U&gt;id&lt;/U&gt; field from &lt;FONT face="courier new,courier"&gt;message&lt;/FONT&gt; field, not from &lt;FONT face="courier new,courier"&gt;_raw&lt;/FONT&gt;, i.e.,&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=message "(SENDER|RECEIVER)\[(?&amp;lt;id&amp;gt;\d+)\]"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 02:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-transaction-Trouble-extracting-first-and-last-messages/m-p/745534#M241478</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-05-06T02:08:26Z</dc:date>
    </item>
  </channel>
</rss>

