<?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: Can you help me build a regex that would parse %host% from the following log directories? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420799#M120912</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;I think the easiesst way is if you use &lt;CODE&gt;host_segment&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;For you this would be&lt;BR /&gt;
&lt;CODE&gt;host_segment = 7&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;See: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/admin/Inputsconf"&gt;https://docs.splunk.com/Documentation/Splunk/latest/admin/Inputsconf&lt;/A&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;If set to N, Splunk software sets the Nth "/"-separated segment of the path as 'host'. &lt;BR /&gt;
For example, if host_segment=3, the third segment is used.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Cheerz,&lt;BR /&gt;
Björn&lt;/P&gt;</description>
    <pubDate>Wed, 05 Dec 2018 20:17:04 GMT</pubDate>
    <dc:creator>bjoernjensen</dc:creator>
    <dc:date>2018-12-05T20:17:04Z</dc:date>
    <item>
      <title>Can you help me build a regex that would parse %host% from the following log directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420798#M120911</link>
      <description>&lt;P&gt;I am trying to use host_regex in input.conf&lt;BR /&gt;
I have log directories as,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/var/log/rsyslog/%year%/%month%/%date%/%host%/syslog

$host$ can be any of following three,
abc-i-1234adfd-foo1 
xx.xx.xx.xx
ip-xx-xx-xx-xx.ec2.internal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 19:07:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420798#M120911</guid>
      <dc:creator>meet_vadaria</dc:creator>
      <dc:date>2018-12-05T19:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me build a regex that would parse %host% from the following log directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420799#M120912</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;I think the easiesst way is if you use &lt;CODE&gt;host_segment&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;For you this would be&lt;BR /&gt;
&lt;CODE&gt;host_segment = 7&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;See: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/admin/Inputsconf"&gt;https://docs.splunk.com/Documentation/Splunk/latest/admin/Inputsconf&lt;/A&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;If set to N, Splunk software sets the Nth "/"-separated segment of the path as 'host'. &lt;BR /&gt;
For example, if host_segment=3, the third segment is used.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Cheerz,&lt;BR /&gt;
Björn&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 20:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420799#M120912</guid>
      <dc:creator>bjoernjensen</dc:creator>
      <dc:date>2018-12-05T20:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me build a regex that would parse %host% from the following log directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420800#M120913</link>
      <description>&lt;P&gt;I tried that. it's working only with following 2 %host% values&lt;BR /&gt;
abc-i-1234adfd-foo1 &lt;BR /&gt;
ip-xx-xx-xx-xx.ec2.internal&lt;/P&gt;

&lt;P&gt;it's not able to extract 3rd value which is xx.xx.xx.xx (IP)&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 20:58:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420800#M120913</guid>
      <dc:creator>meet_vadaria</dc:creator>
      <dc:date>2018-12-05T20:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me build a regex that would parse %host% from the following log directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420801#M120914</link>
      <description>&lt;P&gt;I tried host_segment = 7. I was actually using that. It was working fine until I had %host% = ip-xx-xx-xx-xx.ec2.internal or abc-i-1234adfd-foo1 . &lt;/P&gt;

&lt;P&gt;now, I got this new condition where I am getting ip (XX.XX.XX.XX) in %host%. in this specific case, splunk forwarder is not able to extract IP from that field and it's sending logs with default host (splunk forwarder's hostname) field.&lt;/P&gt;

&lt;P&gt;as it's not working, I want to try out host_regex and see if that works.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 21:01:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420801#M120914</guid>
      <dc:creator>meet_vadaria</dc:creator>
      <dc:date>2018-12-05T21:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me build a regex that would parse %host% from the following log directories?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420802#M120915</link>
      <description>&lt;P&gt;try any one of this in your inputs.conf for host_regex, it helps if you can post the year/month/data format as well to test the regex...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host_regex = /var/log/rsyslog/\d+/\d+\/\d+/([\w\d\\.-]+)\/syslog
host_regex = \/var\/log\/rsyslog\/\d+\/\d+\/\d+\/([\w\d\\.-]+)\/syslog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;lookup this Splunk doc..&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.2.1/Data/Setadefaulthostforaninput#Set_the_event_host_with_the_host_regex_attribute" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/7.2.1/Data/Setadefaulthostforaninput#Set_the_event_host_with_the_host_regex_attribute&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:21:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-build-a-regex-that-would-parse-host-from-the/m-p/420802#M120915</guid>
      <dc:creator>prakash007</dc:creator>
      <dc:date>2020-09-29T22:21:33Z</dc:date>
    </item>
  </channel>
</rss>

