<?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 Can you help me create a regex that would extract a host from a path? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446866#M126730</link>
    <description>&lt;P&gt;How can I extract hostname from the path for host_regex in data input on directory monitoring?&lt;/P&gt;

&lt;P&gt;I need only host name &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/export/var/path/host1.log
/export/var/path/host-02.ac.lp.our.domain.log
/export/var/path/host3.ac.lp.our.domain.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so it should be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host1
host-02
host3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 13 Dec 2018 22:27:32 GMT</pubDate>
    <dc:creator>mlevsh</dc:creator>
    <dc:date>2018-12-13T22:27:32Z</dc:date>
    <item>
      <title>Can you help me create a regex that would extract a host from a path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446866#M126730</link>
      <description>&lt;P&gt;How can I extract hostname from the path for host_regex in data input on directory monitoring?&lt;/P&gt;

&lt;P&gt;I need only host name &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/export/var/path/host1.log
/export/var/path/host-02.ac.lp.our.domain.log
/export/var/path/host3.ac.lp.our.domain.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so it should be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host1
host-02
host3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 22:27:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446866#M126730</guid>
      <dc:creator>mlevsh</dc:creator>
      <dc:date>2018-12-13T22:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me create a regex that would extract a host from a path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446867#M126731</link>
      <description>&lt;P&gt;try this:&lt;BR /&gt;
inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///export/var/path/host*]
host_regex = \/export\/var\/path\/(.*?[^\.]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;regex101 link: &lt;A href="https://regex101.com/r/L4xAkO/1"&gt;https://regex101.com/r/L4xAkO/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;hope it helps&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 23:12:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446867#M126731</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-12-13T23:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me create a regex that would extract a host from a path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446868#M126732</link>
      <description>&lt;P&gt;Thank you so much for your quick reply @adonio&lt;/P&gt;

&lt;P&gt;Expression works on regex101, but when I try it in Splunk (via GUI-&amp;gt; Index once) it doesn't work as expected&lt;/P&gt;

&lt;P&gt;For example:&lt;BR /&gt;
I’ve tried to test  two files  using (.*?[^.]+).&lt;BR /&gt;&lt;BR /&gt;
1) /export/var/path/host1-03.ac.lp.our.domain.log&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Review
Input Type  File Monitor 
Source Path   /export/var/path/host1-03.ac.lp.our.domain.log
Continuously Monitor No, index once
Source Type  syslog
App Context  search
Host Source path regular expression: /export/var/path/(.*?[^\.]+)
Index  testregex
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Got data but  host was set to “host1-03.ac.lp.our.domain”   without .log. &lt;BR /&gt;
The objective to get host set to "host1-03"&lt;/P&gt;

&lt;P&gt;2) But it worked for   /export/var/path/host2b.log&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Review
Input Type File Monitor
Source Path  /export/var/path/host1b.log
Continuously Monitor No, index once
Source Type syslog
App Context search
Host  Source path regular expression: /export/var/path/(.*?[^\.]+)
Index testregex
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Got data and host was set to host1b&lt;/P&gt;

&lt;P&gt;Cannot figure out what I'm missing.&lt;BR /&gt;
Any advice?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 15:28:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446868#M126732</guid>
      <dc:creator>mlevsh</dc:creator>
      <dc:date>2018-12-14T15:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me create a regex that would extract a host from a path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446869#M126733</link>
      <description>&lt;P&gt;Slight simplification of &lt;CODE&gt;\/export\/var\/path\/(.*?[^\.]+)&lt;/CODE&gt; is &lt;CODE&gt;\/export\/var\/path\/(.*?)\.&lt;/CODE&gt; ; -)&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 20:37:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-regex-that-would-extract-a-host-from-a/m-p/446869#M126733</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2018-12-16T20:37:37Z</dc:date>
    </item>
  </channel>
</rss>

