<?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: Set regex hostname from file location in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685374#M114353</link>
    <description>&lt;P&gt;Your regex seems pretty OK. You could try to simplify it a bit (the character class is not needed if you want just one character, slashes don't need escaping and {1,} can be replaced by +)&amp;nbsp; so you could do something like this:&lt;/P&gt;&lt;PRE&gt;(?:/[^/]*)+/(\w*)&lt;/PRE&gt;&lt;P&gt;But you can simplify it even further&lt;/P&gt;&lt;PRE&gt;(?:.*)/(\w*)&lt;/PRE&gt;&lt;P&gt;You could take one thing into account though - a valid hostname can contain a dash which is not included in \w. Also, depending on your environment, if it's a FQDN, it can contain dots.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Apr 2024 22:04:30 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-04-24T22:04:30Z</dc:date>
    <item>
      <title>Set regex hostname from file location</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685370#M114352</link>
      <description>&lt;P&gt;Hi, I am having troubles with providing the correct regex to extract the hostname from the file location. The file structure looks like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;/var/log/syslog/splunk-lb/ise/switch01.log&lt;/P&gt;&lt;P&gt;I need only the switch01 as hostname but splunk add switch01.log.&lt;/P&gt;&lt;P&gt;The regex i use is&amp;nbsp;(?:[\/][^\/]*){1,}[\/](\w*)&lt;/P&gt;&lt;P&gt;Any idea how to modify the regex to match only switch01?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 20:32:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685370#M114352</guid>
      <dc:creator>dersa</dc:creator>
      <dc:date>2024-04-24T20:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Set regex hostname from file location</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685374#M114353</link>
      <description>&lt;P&gt;Your regex seems pretty OK. You could try to simplify it a bit (the character class is not needed if you want just one character, slashes don't need escaping and {1,} can be replaced by +)&amp;nbsp; so you could do something like this:&lt;/P&gt;&lt;PRE&gt;(?:/[^/]*)+/(\w*)&lt;/PRE&gt;&lt;P&gt;But you can simplify it even further&lt;/P&gt;&lt;PRE&gt;(?:.*)/(\w*)&lt;/PRE&gt;&lt;P&gt;You could take one thing into account though - a valid hostname can contain a dash which is not included in \w. Also, depending on your environment, if it's a FQDN, it can contain dots.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 22:04:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685374#M114353</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-24T22:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Set regex hostname from file location</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685392#M114357</link>
      <description>&lt;P&gt;Cheers Rick,&amp;nbsp;&lt;/P&gt;&lt;P&gt;The regex I ended up is like this&amp;nbsp;(?:.*)\/(\w*). The one you suggested,(?:.*)/(\w*), didn't work. &amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks Alex&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 06:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685392#M114357</guid>
      <dc:creator>dersa</dc:creator>
      <dc:date>2024-04-25T06:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Set regex hostname from file location</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685404#M114360</link>
      <description>&lt;P&gt;That is puzzling. If I understand correctly, you're talking about the host_regex setting of the monitor input, right?&lt;/P&gt;&lt;P&gt;The docs don't say that there is any kind of escaping required. If it is however, it would be great if you posted a docs feedback (there is a form at the bottom of &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Admin/Inputsconf" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Admin/Inputsconf&lt;/A&gt; ) describing your situation and how it differs from the described state.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 07:51:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Set-regex-hostname-from-file-location/m-p/685404#M114360</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-25T07:51:24Z</dc:date>
    </item>
  </channel>
</rss>

