<?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: Matching the last instance of &amp;quot;endswith&amp;quot; in a transaction? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94672#M24456</link>
    <description>&lt;P&gt;One issue is that we have to know that the final status is resolved. Using a transaction may find the ticket simply in the open state or any other non-resolved state. So unfortunately we're forced into knowing the create time and deducing the last resolved time.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2011 19:06:00 GMT</pubDate>
    <dc:creator>lisa_1</dc:creator>
    <dc:date>2011-10-19T19:06:00Z</dc:date>
    <item>
      <title>Matching the last instance of "endswith" in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94669#M24453</link>
      <description>&lt;P&gt;The transaction command matches only the first instance of the specified endswith, however it's possible and likely that the transaction doesn't actually end there. Transaction should match on the last instance, but it doesn't.&lt;/P&gt;

&lt;P&gt;Is there a workaround for it? Consider a simple example:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
ticket=4000 transaction_type="Create" ticket_status="new"&lt;BR /&gt;
ticket=4000 transactioon_type="Status" ticket_status="open"&lt;BR /&gt;
ticket=4000 transaction_type="Status" ticket_status="resolved"&lt;BR /&gt;
ticket=4000 transactioon_type="Status" ticket_status="open"&lt;BR /&gt;
ticket=4000 transaction_type="Status" ticket_status="resolved"&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;As you can see the ticket is opened once (&lt;CODE&gt;startswith=Create&lt;/CODE&gt;) but resolved twice with someone reopening the ticket in between. A simple &lt;CODE&gt;endswith=resolved&lt;/CODE&gt; will miss the true resolution of the ticket and all kinds of metrics will be wrong.&lt;/P&gt;

&lt;P&gt;Is there a way to workaround this limitation and capture the final &lt;CODE&gt;ticket_status="resolved"&lt;/CODE&gt; as the true end of the transaction for &lt;CODE&gt;ticket=4000&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 15:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94669#M24453</guid>
      <dc:creator>lisa_1</dc:creator>
      <dc:date>2011-10-19T15:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Matching the last instance of "endswith" in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94670#M24454</link>
      <description>&lt;P&gt;I wouldn't use endswith, since you want all events following "startswith". &lt;/P&gt;

&lt;P&gt;How about: &lt;CODE&gt;|transaction startswith=Create ticket|stats last(ticket_status) by ticket&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 15:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94670#M24454</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2011-10-19T15:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Matching the last instance of "endswith" in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94671#M24455</link>
      <description>&lt;P&gt;In this case, do you need to use &lt;CODE&gt;startswith&lt;/CODE&gt; or &lt;CODE&gt;endswith&lt;/CODE&gt; at all? Can you simply transaction (or stats) on &lt;CODE&gt;ticket&lt;/CODE&gt; alone?&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Updated:&lt;/P&gt;

&lt;P&gt;If you need to know just the last state and time, you can do either:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ticket=* | transaction ticket mvlist=ticket_status | where mvindex(ticket_status,-1)=="resolved" | eval lastresolvedtime=_time+duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ticket=* | stats last(ticket_status) as last_status,first(_time) as start_time,last(_time) as end_time by ticket | where last_status=="resolved
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2011 18:38:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94671#M24455</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-10-19T18:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Matching the last instance of "endswith" in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94672#M24456</link>
      <description>&lt;P&gt;One issue is that we have to know that the final status is resolved. Using a transaction may find the ticket simply in the open state or any other non-resolved state. So unfortunately we're forced into knowing the create time and deducing the last resolved time.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 19:06:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94672#M24456</guid>
      <dc:creator>lisa_1</dc:creator>
      <dc:date>2011-10-19T19:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Matching the last instance of "endswith" in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94673#M24457</link>
      <description>&lt;P&gt;updated answer&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2011 19:39:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-the-last-instance-of-quot-endswith-quot-in-a/m-p/94673#M24457</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-10-19T19:39:47Z</dc:date>
    </item>
  </channel>
</rss>

