<?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 Help with hostname regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-hostname-regex/m-p/122383#M32936</link>
    <description>&lt;P&gt;I have concocted a basic regular expression to find all Splunk indexes from matching hosts. The idea of the regex is to find all indexes by hosts that: &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Begin with "us" or "ln"&lt;/LI&gt;
&lt;LI&gt;The third character (after us or ln) can be any character&lt;/LI&gt;
&lt;LI&gt;The fourth character is an x&lt;/LI&gt;
&lt;LI&gt;The remaining characters can be any character or number&lt;/LI&gt;
&lt;LI&gt;It can also be followed by .intranet.local (but is optional)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;\&lt;/P&gt;

&lt;P&gt;(Also, sourcetype should be from syslog)&lt;/P&gt;

&lt;P&gt;Splunk searches and regexes I have tried are:&lt;/P&gt;

&lt;P&gt;(Note, splunk isn't letting me post back slashes in my code... even if I use quadruple backslashes to try and escape, so imagine the forward slashes below are back slashes)&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;sourcetype=syslog host="(?:us|ln)/w*/.&lt;EM&gt;/w&lt;/EM&gt;/.&lt;EM&gt;/w&lt;/EM&gt;"&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;sourcetype=syslog host_regex="(?:us|ln)/w*/.&lt;EM&gt;/w&lt;/EM&gt;/.&lt;EM&gt;/w&lt;/EM&gt;"&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;sourcetype=syslog regex host="(?:us|ln)/w*/.w/w*/.&lt;EM&gt;/w&lt;/EM&gt;"&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;If I remove the regex section, and do a search with host="*", I receive indexes with host fields such as:&lt;/P&gt;

&lt;P&gt;uslx1099.intranet.local&lt;/P&gt;

&lt;P&gt;uslx508.intranet.local&lt;/P&gt;

&lt;P&gt;mylx091.intranet.local&lt;/P&gt;

&lt;P&gt;usax555&lt;/P&gt;

&lt;P&gt;lnax01b&lt;/P&gt;

&lt;P&gt;Any assistance or clarification as to what I may be doing wrong would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:11:07 GMT</pubDate>
    <dc:creator>herndona</dc:creator>
    <dc:date>2020-09-28T18:11:07Z</dc:date>
    <item>
      <title>Help with hostname regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-hostname-regex/m-p/122383#M32936</link>
      <description>&lt;P&gt;I have concocted a basic regular expression to find all Splunk indexes from matching hosts. The idea of the regex is to find all indexes by hosts that: &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Begin with "us" or "ln"&lt;/LI&gt;
&lt;LI&gt;The third character (after us or ln) can be any character&lt;/LI&gt;
&lt;LI&gt;The fourth character is an x&lt;/LI&gt;
&lt;LI&gt;The remaining characters can be any character or number&lt;/LI&gt;
&lt;LI&gt;It can also be followed by .intranet.local (but is optional)&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;\&lt;/P&gt;

&lt;P&gt;(Also, sourcetype should be from syslog)&lt;/P&gt;

&lt;P&gt;Splunk searches and regexes I have tried are:&lt;/P&gt;

&lt;P&gt;(Note, splunk isn't letting me post back slashes in my code... even if I use quadruple backslashes to try and escape, so imagine the forward slashes below are back slashes)&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;sourcetype=syslog host="(?:us|ln)/w*/.&lt;EM&gt;/w&lt;/EM&gt;/.&lt;EM&gt;/w&lt;/EM&gt;"&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;sourcetype=syslog host_regex="(?:us|ln)/w*/.&lt;EM&gt;/w&lt;/EM&gt;/.&lt;EM&gt;/w&lt;/EM&gt;"&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;sourcetype=syslog regex host="(?:us|ln)/w*/.w/w*/.&lt;EM&gt;/w&lt;/EM&gt;"&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;If I remove the regex section, and do a search with host="*", I receive indexes with host fields such as:&lt;/P&gt;

&lt;P&gt;uslx1099.intranet.local&lt;/P&gt;

&lt;P&gt;uslx508.intranet.local&lt;/P&gt;

&lt;P&gt;mylx091.intranet.local&lt;/P&gt;

&lt;P&gt;usax555&lt;/P&gt;

&lt;P&gt;lnax01b&lt;/P&gt;

&lt;P&gt;Any assistance or clarification as to what I may be doing wrong would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:11:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-hostname-regex/m-p/122383#M32936</guid>
      <dc:creator>herndona</dc:creator>
      <dc:date>2020-09-28T18:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help with hostname regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-hostname-regex/m-p/122384#M32937</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=syslog | where match(host,"(?:us|ln)\wx.*") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Nov 2014 20:39:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-hostname-regex/m-p/122384#M32937</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-11-14T20:39:00Z</dc:date>
    </item>
  </channel>
</rss>

