<?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: serverclass and regex help for wildcard in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318337#M95252</link>
    <description>&lt;P&gt;It's best to be specific as you can be with regex.   If you look for the end of line termination ("$") then you can account for the optional domain levels :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;whitelist.0 = myhost(?:(?:\.internal)?\.co\.uk)?$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Dec 2017 14:35:34 GMT</pubDate>
    <dc:creator>wenthold</dc:creator>
    <dc:date>2017-12-04T14:35:34Z</dc:date>
    <item>
      <title>serverclass and regex help for wildcard</title>
      <link>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318333#M95248</link>
      <description>&lt;P&gt;We have got few servers which could come with or without FQDN in its name. I'm not sure how Splunk UF generates the hostname of the servers, but it seems not consistent.&lt;BR /&gt;
So have to filter serverclass to accomodate this&lt;/P&gt;

&lt;P&gt;Two questions&lt;BR /&gt;
1. Is Serverclass able to accomodate proper regex in whitelist?&lt;BR /&gt;
2. Help with regex below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# below is sample hostnames
myhost.co.uk
myhost
myhost.internal.co.uk
myhostIncorrect.co.uk
somemyhostidontwant.co.uk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to extract only&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myhost.co.uk
myhost
myhost.internal.co.uk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/qgKCxP/1"&gt;https://regex101.com/r/qgKCxP/1&lt;/A&gt;&lt;BR /&gt;
I'm using &lt;CODE&gt;myhost(?:\.)?.*&lt;/CODE&gt;  but it is capturing &lt;CODE&gt;myhostIncorrect.co.uk&lt;/CODE&gt; which I don't require. How to make it strict so it collects &lt;CODE&gt;myhost &amp;amp;&amp;amp; myhost\.*&lt;/CODE&gt; in a single expression?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 13:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318333#M95248</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-12-03T13:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: serverclass and regex help for wildcard</title>
      <link>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318334#M95249</link>
      <description>&lt;P&gt;Yes PCRE regex is supported in whitelists and blacklists.&lt;/P&gt;

&lt;P&gt;From serverass.conf.spec&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; * These patterns are PCRE regular expressions, with the following aids for easier entry:
 * You can specify simply '.' to mean '\.'
 * You can specify simply '*' to mean '.*'
 * Matches are always case-insensitive; you do not need to specify the '(?i)' prefix.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also you don’t need the ^ because all splunk regexes are anchored to the start.  &lt;/P&gt;

&lt;P&gt;You could match al the same matches in your regex101 example with the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;whitelist.0=myhost*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;By the way, see this answer for how splunk determines the forwarder name:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/171928/how-can-i-control-the-clients-host-name-that-appea.html"&gt;https://answers.splunk.com/answers/171928/how-can-i-control-the-clients-host-name-that-appea.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 14:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318334#M95249</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-12-03T14:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: serverclass and regex help for wildcard</title>
      <link>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318335#M95250</link>
      <description>&lt;P&gt;hi jKat, thanks for your reply. I had seen the above spec but still not able to my question.  I can see how to override the hostname, but I was looking something more intrinsic on "How Splunk determines" the hostname on startup.  Does it use something like &lt;CODE&gt;hostname -s&lt;/CODE&gt;  or &lt;CODE&gt;hostname&lt;/CODE&gt; or something internal ?  This way  I could write a script to determine the expected hostnames of the client.&lt;/P&gt;

&lt;P&gt;Regarding, regex unfortunately your above example  &lt;CODE&gt;myhost*&lt;/CODE&gt; will capture  &lt;CODE&gt;myhostIncorrect.co.uk&lt;/CODE&gt;  which is not required.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 15:16:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318335#M95250</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-12-03T15:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: serverclass and regex help for wildcard</title>
      <link>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318336#M95251</link>
      <description>&lt;P&gt;Yes it’s whatever is returned by hostname command on install.  See this answer for a deeper explanation:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/154999/how-can-i-change-the-default-hostname-in-splunk.html"&gt;https://answers.splunk.com/answers/154999/how-can-i-change-the-default-hostname-in-splunk.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;For your regex, you should probably use a blacklist in conjunction with a whitelist.  Today you don’t want myhostWrongName tomorrow you don’t want myhostSomeOtherName and one regex won’t cover all the scenarios you’ll come up with.  So just use * and . and whitelists in conjunction with blacklists.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2017 16:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318336#M95251</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-12-03T16:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: serverclass and regex help for wildcard</title>
      <link>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318337#M95252</link>
      <description>&lt;P&gt;It's best to be specific as you can be with regex.   If you look for the end of line termination ("$") then you can account for the optional domain levels :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;whitelist.0 = myhost(?:(?:\.internal)?\.co\.uk)?$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Dec 2017 14:35:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/serverclass-and-regex-help-for-wildcard/m-p/318337#M95252</guid>
      <dc:creator>wenthold</dc:creator>
      <dc:date>2017-12-04T14:35:34Z</dc:date>
    </item>
  </channel>
</rss>

