<?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 Regex for dynamic string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183008#M52694</link>
    <description>&lt;P&gt;Hey together,&lt;/P&gt;

&lt;P&gt;My input is a dynamic input:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;SysH=1.0;MemU=4871;MemF=3173;SwpU=5227;SwpF=10860;PrcC=95; &lt;STRONG&gt;eclipse.exe=0.175&lt;/STRONG&gt;, &lt;STRONG&gt;firefox.exe=0.04&lt;/STRONG&gt;, Dwm.exe=0.028, &lt;STRONG&gt;javaw.exe=0.025&lt;/STRONG&gt;, Explorer.EXE=0.016; &lt;STRONG&gt;eclipse.exe=1611500&lt;/STRONG&gt;, &lt;STRONG&gt;firefox.exe=1393504&lt;/STRONG&gt;, &lt;STRONG&gt;javaw.exe=1180432&lt;/STRONG&gt;, sidebar.exe=741164, PrivacyIconClient.exe=643392;CPUH=0.92;CPULd=0.08;CPUNonIdl=0.11;MemH=1.0;NetDownR=983399, eth7=0, eth6=0, eth11=0, eth0=0;NetUpR=17994, eth7=0, eth6=0, eth11=0, eth0=0;=0, eth10=0, eth12=0, eth15=0, eth9=0, eth14=0;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;As you can see, I've got two fields with the same name but different values. What I wanna do is &lt;STRONG&gt;to add an "m_" in front of the name of the bigger one&lt;/STRONG&gt;. I guess it's just possible with &lt;STRONG&gt;regex&lt;/STRONG&gt;. &lt;BR /&gt;
In fact, I would not ask you for that if it was a static input. &lt;BR /&gt;
The &lt;STRONG&gt;programm.exe parts are dynamic&lt;/STRONG&gt;. But I really need to find a way to rename one of the fields in every case. &lt;/P&gt;

&lt;P&gt;Hope some of you can help me.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2013 11:15:59 GMT</pubDate>
    <dc:creator>Dreads94</dc:creator>
    <dc:date>2013-12-18T11:15:59Z</dc:date>
    <item>
      <title>Regex for dynamic string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183008#M52694</link>
      <description>&lt;P&gt;Hey together,&lt;/P&gt;

&lt;P&gt;My input is a dynamic input:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;SysH=1.0;MemU=4871;MemF=3173;SwpU=5227;SwpF=10860;PrcC=95; &lt;STRONG&gt;eclipse.exe=0.175&lt;/STRONG&gt;, &lt;STRONG&gt;firefox.exe=0.04&lt;/STRONG&gt;, Dwm.exe=0.028, &lt;STRONG&gt;javaw.exe=0.025&lt;/STRONG&gt;, Explorer.EXE=0.016; &lt;STRONG&gt;eclipse.exe=1611500&lt;/STRONG&gt;, &lt;STRONG&gt;firefox.exe=1393504&lt;/STRONG&gt;, &lt;STRONG&gt;javaw.exe=1180432&lt;/STRONG&gt;, sidebar.exe=741164, PrivacyIconClient.exe=643392;CPUH=0.92;CPULd=0.08;CPUNonIdl=0.11;MemH=1.0;NetDownR=983399, eth7=0, eth6=0, eth11=0, eth0=0;NetUpR=17994, eth7=0, eth6=0, eth11=0, eth0=0;=0, eth10=0, eth12=0, eth15=0, eth9=0, eth14=0;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;As you can see, I've got two fields with the same name but different values. What I wanna do is &lt;STRONG&gt;to add an "m_" in front of the name of the bigger one&lt;/STRONG&gt;. I guess it's just possible with &lt;STRONG&gt;regex&lt;/STRONG&gt;. &lt;BR /&gt;
In fact, I would not ask you for that if it was a static input. &lt;BR /&gt;
The &lt;STRONG&gt;programm.exe parts are dynamic&lt;/STRONG&gt;. But I really need to find a way to rename one of the fields in every case. &lt;/P&gt;

&lt;P&gt;Hope some of you can help me.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2013 11:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183008#M52694</guid>
      <dc:creator>Dreads94</dc:creator>
      <dc:date>2013-12-18T11:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for dynamic string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183009#M52695</link>
      <description>&lt;P&gt;The easiest solution is probably to rewrite the events with SEDCMD in props.conf on your indexer (or Heavy Forwarder);&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your sourcetype]
SEDCMD-blah = s/(\w+\.exe=\d{4,})/m_\1/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see, there are some assumptions here;&lt;BR /&gt;
1) that all the stuff you want to rename ends in .exe&lt;BR /&gt;
2) that they have at least a 4-digit value (i.e. greater than 1000)&lt;BR /&gt;
3) that the binaries (i.e. field names) can contain only certain characters.&lt;/P&gt;

&lt;P&gt;Adjust these things to suit your actual environment. Please note that this will actually change the events before the are written to disk, so if your'e not allowed to tamper with the data, this might not be the way to go. &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;Perhaps I should also explain what to do instead &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;It's essentially the same type of regex. While it &lt;EM&gt;looks&lt;/EM&gt; like the events are altered, they are in fact not. Since the rex operates on the &lt;CODE&gt;_raw&lt;/CODE&gt; field, they will look different in the search results. However, that change is not permanent.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search for events 
| fields + _raw 
| rex field=_raw mode=sed "s/(\w+\.exe=\d{4,})/m_\1/g" 
| kv kvdelim="="
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First you clear all the fields except &lt;CODE&gt;_raw&lt;/CODE&gt;, then do the &lt;CODE&gt;rex&lt;/CODE&gt; renaming, then extract the fields.&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;K&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2013 14:46:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183009#M52695</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-12-18T14:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for dynamic string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183010#M52696</link>
      <description>&lt;P&gt;updated with search-time voodoo as well.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2013 15:22:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183010#M52696</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-12-18T15:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for dynamic string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183011#M52697</link>
      <description>&lt;P&gt;great! Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2013 09:09:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-dynamic-string/m-p/183011#M52697</guid>
      <dc:creator>Dreads94</dc:creator>
      <dc:date>2013-12-19T09:09:42Z</dc:date>
    </item>
  </channel>
</rss>

