<?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: RegEx - Get integer behind string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102565#M26511</link>
    <description>&lt;P&gt;Hi Kristian,&lt;/P&gt;

&lt;P&gt;thank you for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I forgot to mention that I'm also completely new to Splunk itself ^^&lt;BR /&gt;
So I'm not sure how to add your expression to Splunk.&lt;/P&gt;

&lt;P&gt;The only way I know so far is to do this with the "Interactive field extractor".&lt;BR /&gt;
But when I insert the phrase in the "Edit" field Splunk returns a syntax error.&lt;/P&gt;

&lt;P&gt;Edit1: okay I've got it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  Iserted the expression into the normal search and found the new field err_code.&lt;BR /&gt;
Thank you so much Kristian!!&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2013 07:27:07 GMT</pubDate>
    <dc:creator>lirumlarum</dc:creator>
    <dc:date>2013-04-22T07:27:07Z</dc:date>
    <item>
      <title>RegEx - Get integer behind string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102563#M26509</link>
      <description>&lt;P&gt;Hi guys, &lt;BR /&gt;
I'm absolutely new to RegEx and I'm very fascinated how powerfull RegEx is.&lt;/P&gt;

&lt;P&gt;I'm trying to get an integer value that is placed behind a specific string.&lt;BR /&gt;
This string and the integer value may appear at several places in a logfile.&lt;/P&gt;

&lt;P&gt;Here is an example of the file:&lt;/P&gt;

&lt;P&gt;4/11/2013;4:22:00 PM;Server konnte nicht gestartet werden, falsche Server IP/Name&lt;/P&gt;

&lt;P&gt;4/13/2013;2:26:31 PM;Server konnte nicht gestartet werden, falsche Server IP/Name&lt;/P&gt;

&lt;P&gt;4/14/2013;2:01:01 AM;Backup Fehler: (db1)&lt;/P&gt;

&lt;P&gt;4/14/2013;2:01:02 AM;&lt;/P&gt;

&lt;P&gt;4/14/2013;2:01:03 AM;ErrorCode: &lt;STRONG&gt;17&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Server offline&lt;/P&gt;

&lt;P&gt;Der Datenbankeserver reagiert nicht.&lt;/P&gt;

&lt;P&gt;I've been playing around with PowerGREP and RegexMagic but I didn't create one single expression that is correct for Splunk ^^&lt;/P&gt;

&lt;P&gt;All I want to create is a new field, with the ErrorCode integer to get an overview which errors occur how often.&lt;/P&gt;

&lt;P&gt;Can someone help me with creating this expression?&lt;BR /&gt;
Thank you in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 06:31:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102563#M26509</guid>
      <dc:creator>lirumlarum</dc:creator>
      <dc:date>2013-04-22T06:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx - Get integer behind string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102564#M26510</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;your base search | rex "ErrorCode:\s+(?&amp;lt;err_code&amp;gt;\d+)"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This should give you a field called &lt;CODE&gt;err_code&lt;/CODE&gt; which contains the ErrorCode. You can then use it in &lt;CODE&gt;stats/tables/charts&lt;/CODE&gt; for reporting, e.g.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | timechart span=1h count by err_code&lt;/CODE&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;Aah, &lt;/P&gt;

&lt;P&gt;The examples above are for the use in an ordinary search, i.e. you enter it into the search bar. &lt;CODE&gt;your base search&lt;/CODE&gt; would be where you put your &lt;CODE&gt;sourcetype=xxx&lt;/CODE&gt; etc. &lt;BR /&gt;
The &lt;CODE&gt;...&lt;/CODE&gt; referrs to any previous search statements.&lt;/P&gt;

&lt;P&gt;To make it more permanent, you can enter it into the props.conf file (either manually or through the IFX).&lt;/P&gt;

&lt;P&gt;The IFX 'syntax' if you were to edit the generated regex, would probably look like;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;ErrorCode:\s+(?P&amp;lt;FIELDNAME&amp;gt;\d+)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Then you'll be prompted to give a name for the field (FIELDNAME is just a placeholder).&lt;/P&gt;

&lt;P&gt;Or you can put it in the props.conf directly;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[your_sourcetype]&lt;BR /&gt;
EXTRACT-blah =  ErrorCode:\s+(?&amp;lt;err_code&amp;gt;\d+)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 07:13:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102564#M26510</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-04-22T07:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx - Get integer behind string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102565#M26511</link>
      <description>&lt;P&gt;Hi Kristian,&lt;/P&gt;

&lt;P&gt;thank you for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I forgot to mention that I'm also completely new to Splunk itself ^^&lt;BR /&gt;
So I'm not sure how to add your expression to Splunk.&lt;/P&gt;

&lt;P&gt;The only way I know so far is to do this with the "Interactive field extractor".&lt;BR /&gt;
But when I insert the phrase in the "Edit" field Splunk returns a syntax error.&lt;/P&gt;

&lt;P&gt;Edit1: okay I've got it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  Iserted the expression into the normal search and found the new field err_code.&lt;BR /&gt;
Thank you so much Kristian!!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2013 07:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-Get-integer-behind-string/m-p/102565#M26511</guid>
      <dc:creator>lirumlarum</dc:creator>
      <dc:date>2013-04-22T07:27:07Z</dc:date>
    </item>
  </channel>
</rss>

