<?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: Exclude characters within a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25368#M4774</link>
    <description>&lt;P&gt;Yes, the backslashes are in place. Somehow I pasted the wrong code. This is the correct one.&lt;BR /&gt;
&lt;CODE&gt;sourcetype=ps OR sourcetype=top COMMAND | rex field=_raw "[(?&lt;PROCESS&gt;\S+)]" | rex field=process mode=sed "s#/\d+]#]#" | stats count by process&lt;/PROCESS&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Yes, a new field named "process" appeared.&lt;/P&gt;

&lt;P&gt;But still no luck and for some reason it only shows me three process names.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Feb 2013 11:35:26 GMT</pubDate>
    <dc:creator>lemikg</dc:creator>
    <dc:date>2013-02-12T11:35:26Z</dc:date>
    <item>
      <title>Exclude characters within a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25364#M4770</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;right now I am having trouble exluding characters like "/, :, 0-9" from my search. &lt;DEL&gt;I want those excluded &lt;/DEL&gt; &lt;/P&gt;

&lt;P&gt;I think best would be to look at the end of the name and if there is a "_" or a "/" then cut that and everything behind it so I can count the services for each host.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;-bash
[aio/0]
[aio/1]
[aio/2]
[aio/3]
[async/mgr]
[ata/0]
[ata/1]
[ata/2]
[ata/3]
[ata_aux]
[bdi-default]
[bond0]
[cpuset]
[crypto/0]
[crypto/1]
[crypto/2]
[crypto/3]&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I want to see for example is &lt;STRONG&gt;"[aio]"&lt;/STRONG&gt; and this search worked but I can't figure out how to add more characters to it.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;sourcetype=ps OR sourcetype=top COMMAND | multikv | makemv delim="/" COMMAND&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Can anyone help me here?&lt;/P&gt;

&lt;P&gt;Thanks in advance and best regards&lt;BR /&gt;
Mike&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;:::::::::::::::UPDATE:::::::::::::::&lt;/STRONG&gt;&lt;BR /&gt;
I made something that worked to a certain point (I'll get to that later) but is probably inefficient and not 100% the solution.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=top COMMAND | multikv | rex field=COMMAND "^(?&lt;COMMAND&gt;.+?)\/" | makemv delim="[" COMMAND | eval new_command = replace(COMMAND,"]","") | stats count by new_command&lt;/COMMAND&gt;&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This seach lacks the ability to cut off two characters, &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;"_"&lt;/LI&gt;
&lt;LI&gt;a number&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 08 Feb 2013 14:39:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25364#M4770</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-08T14:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude characters within a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25365#M4771</link>
      <description>&lt;P&gt;Try using "rex" command this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=ps OR sourcetype=top COMMAND | rex field=process mode=sed "s#/\d+\]#\]#" | chart count by process host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to obtain what you asked, assuming that "process" is the field already extracted from this sourcetype. Otherwise, add this "rex" before the other one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "\[(?&amp;lt;process&amp;gt;\S+)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
Stefano&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2013 16:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25365#M4771</guid>
      <dc:creator>stefano_guidoba</dc:creator>
      <dc:date>2013-02-08T16:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude characters within a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25366#M4772</link>
      <description>&lt;P&gt;thanks Stefano! process has not yet been extracted. &lt;/P&gt;

&lt;P&gt;I tried the following:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;sourcetype=ps OR sourcetype=top COMMAND | rex field=_raw "[(?&lt;PROCESS&gt;\S+)]" | rex field=process mode=sed "s#/\d+]#]#" | chart count by process host&lt;/PROCESS&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;
But it isn't what I expected.&lt;/P&gt;

&lt;P&gt;I think best would be to look at the end of the name and if there is a "_" or a "/" then cut that and everything behind it.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 10:48:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25366#M4772</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-12T10:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude characters within a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25367#M4773</link>
      <description>&lt;P&gt;Are you putting \ (backslashes) where I put them, right? Running my search, does a new field named "process" appear on the left?&lt;BR /&gt;
Also, last tip: you want to count by host, so substitute "chart count by process host" with "stats count by host". Try this and let me know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 10:54:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25367#M4773</guid>
      <dc:creator>stefano_guidoba</dc:creator>
      <dc:date>2013-02-12T10:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude characters within a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25368#M4774</link>
      <description>&lt;P&gt;Yes, the backslashes are in place. Somehow I pasted the wrong code. This is the correct one.&lt;BR /&gt;
&lt;CODE&gt;sourcetype=ps OR sourcetype=top COMMAND | rex field=_raw "[(?&lt;PROCESS&gt;\S+)]" | rex field=process mode=sed "s#/\d+]#]#" | stats count by process&lt;/PROCESS&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Yes, a new field named "process" appeared.&lt;/P&gt;

&lt;P&gt;But still no luck and for some reason it only shows me three process names.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 11:35:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25368#M4774</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-12T11:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude characters within a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25369#M4775</link>
      <description>&lt;P&gt;Well, I think I found another workaround. I just replaced the "/" of the first rex with a "_" in the second rex command. Don't know if this can be done more efficient. But so far the result seems to be good.&lt;/P&gt;

&lt;P&gt;&lt;PRE&gt;&lt;CODE&gt;sourcetype=top COMMAND | &lt;BR /&gt;
multikv | &lt;BR /&gt;
rex field=COMMAND "^(?&lt;COMMAND&gt;.+?)\/" | &lt;BR /&gt;
rex field=COMMAND "^(?&lt;COMMAND&gt;.+?)_" | &lt;BR /&gt;
stats count by COMMAND | &lt;BR /&gt;
dedup COMMAND&lt;/COMMAND&gt;&lt;/COMMAND&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2013 11:58:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Exclude-characters-within-a-field/m-p/25369#M4775</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-12T11:58:06Z</dc:date>
    </item>
  </channel>
</rss>

