<?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 extract the prefixed words from logs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495503#M194576</link>
    <description>&lt;P&gt;Hi @Noah_Woodcock &lt;/P&gt;

&lt;P&gt;Think you have got me wrong.&lt;BR /&gt;
I wanted to extract only the very first word that comes before the word error.&lt;/P&gt;

&lt;P&gt;So in my initial question,I have shared the sample as below.&lt;/P&gt;

&lt;P&gt;Null.set.error&lt;BR /&gt;
Nullerror&lt;BR /&gt;
Set-get-error&lt;BR /&gt;
Timed out error&lt;BR /&gt;
Unknown - error&lt;/P&gt;

&lt;P&gt;and the regex that has been suggested (rex "(?.+?)[\s.-]*error") seem to capture everything that is present before the word error.&lt;/P&gt;

&lt;P&gt;For Example:&lt;BR /&gt;
In the below log,&lt;BR /&gt;
Could not complete.Reason : Null.set.error&lt;/P&gt;

&lt;P&gt;The expected is only &lt;STRONG&gt;Null.set&lt;/STRONG&gt; but the its extracting me 'Could not complete.Reason : Null.set'&lt;/P&gt;</description>
    <pubDate>Thu, 05 Dec 2019 16:25:15 GMT</pubDate>
    <dc:creator>prettysunshinez</dc:creator>
    <dc:date>2019-12-05T16:25:15Z</dc:date>
    <item>
      <title>How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495498#M194571</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;
I require help in extracting the words that appear right before the word.&lt;BR /&gt;
Example:&lt;BR /&gt;
Null.set.error&lt;BR /&gt;
Nullerror&lt;BR /&gt;
Set-get-error&lt;BR /&gt;
Timed out error&lt;BR /&gt;
Unknown - error&lt;/P&gt;

&lt;P&gt;From the above,the expected result is&lt;BR /&gt;
Null.set&lt;BR /&gt;
Null&lt;BR /&gt;
Set-get&lt;BR /&gt;
Timed out&lt;BR /&gt;
Unknown&lt;/P&gt;

&lt;P&gt;Kindly help me with this.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 01 Dec 2019 17:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495498#M194571</guid>
      <dc:creator>prettysunshinez</dc:creator>
      <dc:date>2019-12-01T17:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495499#M194572</link>
      <description>&lt;P&gt;Hi prettysunshinez,&lt;/P&gt;

&lt;P&gt;Based on the provided examples, give this a try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search here | rex "(?&amp;lt;ThisIsWhatYouWant&amp;gt;.+?)[\s\.-]*error"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt; After some feedback and new examples the correct regex is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your search here | rex "(?&amp;lt;ThisIsWhatYouWant&amp;gt;[a-zA-Z]+[-\.\s]?[a-zA-Z]+)[\s\.-]*error"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Dec 2019 20:32:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495499#M194572</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-12-01T20:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495500#M194573</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex ":\s*(?&amp;lt;error_prefix&amp;gt;.*?)[^A-z]+\s+error"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Dec 2019 22:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495500#M194573</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-01T22:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495501#M194574</link>
      <description>&lt;P&gt;Hi @MuS,&lt;BR /&gt;
Thanks for your help.&lt;BR /&gt;
This seems to work but this seems to capture all the words that are present before the word error&lt;/P&gt;

&lt;P&gt;For Example:&lt;BR /&gt;
In the below log,&lt;BR /&gt;
Could not complete.Reason : Null.set.error &lt;/P&gt;

&lt;P&gt;The expected is only Null.set but the its extracting me '&lt;STRONG&gt;Could not complete.Reason : Null.set&lt;/STRONG&gt;'&lt;/P&gt;

&lt;P&gt;Likewise for the others also.&lt;/P&gt;

&lt;P&gt;Could you kindly help.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 15:46:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495501#M194574</guid>
      <dc:creator>prettysunshinez</dc:creator>
      <dc:date>2019-12-05T15:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495502#M194575</link>
      <description>&lt;P&gt;I updated my answer.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 15:57:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495502#M194575</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-05T15:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495503#M194576</link>
      <description>&lt;P&gt;Hi @Noah_Woodcock &lt;/P&gt;

&lt;P&gt;Think you have got me wrong.&lt;BR /&gt;
I wanted to extract only the very first word that comes before the word error.&lt;/P&gt;

&lt;P&gt;So in my initial question,I have shared the sample as below.&lt;/P&gt;

&lt;P&gt;Null.set.error&lt;BR /&gt;
Nullerror&lt;BR /&gt;
Set-get-error&lt;BR /&gt;
Timed out error&lt;BR /&gt;
Unknown - error&lt;/P&gt;

&lt;P&gt;and the regex that has been suggested (rex "(?.+?)[\s.-]*error") seem to capture everything that is present before the word error.&lt;/P&gt;

&lt;P&gt;For Example:&lt;BR /&gt;
In the below log,&lt;BR /&gt;
Could not complete.Reason : Null.set.error&lt;/P&gt;

&lt;P&gt;The expected is only &lt;STRONG&gt;Null.set&lt;/STRONG&gt; but the its extracting me 'Could not complete.Reason : Null.set'&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 16:25:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495503#M194576</guid>
      <dc:creator>prettysunshinez</dc:creator>
      <dc:date>2019-12-05T16:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495504#M194577</link>
      <description>&lt;P&gt;Hi prettysunshinez,&lt;/P&gt;

&lt;P&gt;well you did not provided that example in your question so my regex was based on what you provided &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; But try this regex :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; "(?&amp;lt;ThisIsWhatYouWant&amp;gt;[a-zA-Z]+[-\.\s]?[a-zA-Z]+)[\s\.-]*error" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will also match correctly with the new example that you just provided &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 17:46:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495504#M194577</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-12-05T17:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495505#M194578</link>
      <description>&lt;P&gt;Hi @MuS &lt;BR /&gt;
Thanks! This works fine &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 18:00:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495505#M194578</guid>
      <dc:creator>prettysunshinez</dc:creator>
      <dc:date>2019-12-05T18:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the prefixed words from logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495506#M194579</link>
      <description>&lt;P&gt;You're welcome and thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2019 18:05:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-prefixed-words-from-logs/m-p/495506#M194579</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-12-05T18:05:35Z</dc:date>
    </item>
  </channel>
</rss>

