<?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 search from last occurrence of a string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464642#M130945</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw "\[(?&amp;lt;name&amp;gt;.*?\,.*?)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;simply.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Feb 2020 20:28:17 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-02-11T20:28:17Z</dc:date>
    <item>
      <title>How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464637#M130940</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;

&lt;P&gt;I am trying to read the text from the last square bracket (which is TestModelCompany,en_US)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;21:11:31,367 INFO  [TestBenuLogger] [155.56.208.68] [716057]  [-] [TestModelCompany,en_US] No 1 XX_TimeStep="10" XX_TimeQuery="10" XX_HTTPSession="1398708550-1911P0" XX_QuerySession="null" XX_TimeStamp="2020-02-09T20:11:31.358Z-PY" XX_Company="Model Company" XX_QueryMode="STANDARD" XX_Agent="Model"

Starting Model API :
Mode       : Standard
Query Operation : QUERY
Company         : Model Company
New Snapshot Calculation 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wrote a regular expression to extract the content from last bracket,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;=\[)[^\[\]]*(?=][^\[\]]+$)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works well. However I am unable to integrate it in the splunk,&lt;/P&gt;

&lt;P&gt;This is my existing splunk query,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=text XX_Company="*" last_modified_on index="*_test_application" | rex field=_raw "last_modified_on.*?to_datetime\('(?&amp;lt;lmo_date&amp;gt;.*?):\d\d\w\'"  | eval lmo_date_converted=strptime(lmo_date,"%Y-%m-%dT%H:%M") |  eval daysDiff=(_time-lmo_date_converted)/86400 | rex field=_raw "(?&amp;lt;name&amp;gt;&amp;lt;=\[)[^\[\]]*(?=][^\[\]]+$)"  | where daysDiff &amp;gt; 90  | stats avg(daysDiff) as "Last Modified On averege days in past", max(daysDiff) as "Max Value Of Last Modified On"  by  XX_Company XX_Mode | sort -"Last Modified On averege days in past"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is a working splunk query. With this, I would like to display the content from the last bracket as a column. Could you guide?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 17:12:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464637#M130940</guid>
      <dc:creator>benuantony</dc:creator>
      <dc:date>2020-02-10T17:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464638#M130941</link>
      <description>&lt;P&gt;try adjusting your second rex: rex field=_raw &lt;CODE&gt;"(?&amp;lt;name&amp;gt;(?&amp;lt;=\[)[^\[\]]*)(?=][^\[\]]+$)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 21:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464638#M130941</guid>
      <dc:creator>wneighbo</dc:creator>
      <dc:date>2020-02-10T21:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464639#M130942</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| stats values(name) as name avg(daysDiff) as "Last Modified On averege days in past", max(daysDiff) as "Max Value Of Last Modified On"  by  XX_Company XX_Mode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I fix &lt;CODE&gt;stats&lt;/CODE&gt; .&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 22:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464639#M130942</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-10T22:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464640#M130943</link>
      <description>&lt;P&gt;I just need to add a new column with my regex. The stats is already working well&lt;/P&gt;

&lt;P&gt;The regular expression to extract the content from last bracket is this,&lt;/P&gt;

&lt;P&gt;(?&amp;lt;=[)[^[]]*(?=][^[]]+$)&lt;/P&gt;

&lt;P&gt;How to add this in rex &amp;amp; show it as a column with existing query?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 13:47:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464640#M130943</guid>
      <dc:creator>benuantony</dc:creator>
      <dc:date>2020-02-11T13:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464641#M130944</link>
      <description>&lt;P&gt;what is wrong in this?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 13:49:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464641#M130944</guid>
      <dc:creator>benuantony</dc:creator>
      <dc:date>2020-02-11T13:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464642#M130945</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;|rex field=_raw "\[(?&amp;lt;name&amp;gt;.*?\,.*?)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;simply.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 20:28:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464642#M130945</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-11T20:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464643#M130946</link>
      <description>&lt;P&gt;Do you try my last answer? &lt;CODE&gt;name&lt;/CODE&gt; value is appeared.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 20:29:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464643#M130946</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-11T20:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464644#M130947</link>
      <description>&lt;P&gt;any idea?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 20:41:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464644#M130947</guid>
      <dc:creator>benuantony</dc:creator>
      <dc:date>2020-02-11T20:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464645#M130948</link>
      <description>&lt;P&gt;Is the log format constant? If yes, the name you're trying to extract is 5th &lt;CODE&gt;[...]&lt;/CODE&gt; element. Extract that base on number and add &lt;CODE&gt;name&lt;/CODE&gt; to your stats-by clause.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 21:17:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464645#M130948</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-02-11T21:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464646#M130949</link>
      <description>&lt;P&gt;ok.. how to display the variable "name" as column in statistics? I would like to test your rex field=_raw "[(?.&lt;EM&gt;?\,.&lt;/EM&gt;?)]"&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 21:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464646#M130949</guid>
      <dc:creator>benuantony</dc:creator>
      <dc:date>2020-02-11T21:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to search from last occurrence of a string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464647#M130950</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=text XX_Company="*" last_modified_on index="*_test_application" | rex field=_raw "last_modified_on.*?to_datetime\('(?&amp;lt;lmo_date&amp;gt;.*?):\d\d\w\'"  | eval lmo_date_converted=strptime(lmo_date,"%Y-%m-%dT%H:%M") |  eval daysDiff=(_time-lmo_date_converted)/86400  | where daysDiff &amp;gt; 90 | rex field=_raw "^([^\[]+\[){5}(?&amp;lt;name&amp;gt;[^\]]+)"   | stats avg(daysDiff) as "Last Modified On averege days in past", max(daysDiff) as "Max Value Of Last Modified On"  by  XX_Company XX_Mode name | sort -"Last Modified On averege days in past"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Feb 2020 21:37:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-from-last-occurrence-of-a-string/m-p/464647#M130950</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-02-11T21:37:02Z</dc:date>
    </item>
  </channel>
</rss>

