<?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: host_regex to determine IP address in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84875#M21631</link>
    <description>&lt;P&gt;That did it.  Tested and I'm now pulling out the IP.  Many thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2013 16:19:59 GMT</pubDate>
    <dc:creator>wbfoxii</dc:creator>
    <dc:date>2013-04-04T16:19:59Z</dc:date>
    <item>
      <title>host_regex to determine IP address</title>
      <link>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84872#M21628</link>
      <description>&lt;P&gt;I've got these logs from a number of sources that have inconsistent filenames - here are some examples:&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
AA000-77-100.100.100.100_abc__09348450.log&lt;BR /&gt;
AA_000_100.200.100.100__abc__9038509485.log&lt;BR /&gt;
100.210.100.100_abc__983475984759.log&lt;BR /&gt;
AA000-110.200.100.110_abc__98234793437.log&lt;BR /&gt;
AA0000-100.220.100.100_abc__9283492349.log&lt;BR /&gt;
&lt;/PRE&gt;&lt;BR /&gt;
I'm using the following statement in the [monitor://] stanza, hoping to pull out the IP address for a host.&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
[monitor:///opt/splunk/var/log/test]&lt;BR /&gt;
host_regex=.*[_-]+(?&amp;lt; host &amp;gt;\d+\.\d+\.\d+\.\d+)&lt;BR /&gt;
(no spaces around "host", but it won't display unless I put them there)&lt;BR /&gt;
&lt;/PRE&gt;&lt;BR /&gt;
That works for all of the names except the one that leads with the IP address.  Any ideas about how I could make that one work?  I was thinking that lookbehind might help, but I just don't understand regex that well.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:40:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84872#M21628</guid>
      <dc:creator>wbfoxii</dc:creator>
      <dc:date>2020-09-28T13:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: host_regex to determine IP address</title>
      <link>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84873#M21629</link>
      <description>&lt;P&gt;Here is the regex that I got to work with your data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[-_]?(?&amp;lt;host&amp;gt;\d+\.\d+\.\d+\.\d+)_+\w+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now let's analyze your regex and why it was not working. As a general rule you want to avoid using ".*" because it is too greedy. So I removed that and also I replaced the "+" with a "?". The "+" means 1 or more while the "?" means 0 or more because sometimes there isn't any dash or underscore in the name. Another general rule is to work backwards sometimes that is why I ended with an underscore "+" and a \w+. &lt;/P&gt;

&lt;P&gt;Hope this helps. &lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2013 14:38:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84873#M21629</guid>
      <dc:creator>tgow</dc:creator>
      <dc:date>2013-04-04T14:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: host_regex to determine IP address</title>
      <link>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84874#M21630</link>
      <description>&lt;P&gt;"?" means 0 or 1 (greedily)&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2013 14:45:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84874#M21630</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-04-04T14:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: host_regex to determine IP address</title>
      <link>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84875#M21631</link>
      <description>&lt;P&gt;That did it.  Tested and I'm now pulling out the IP.  Many thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2013 16:19:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/host-regex-to-determine-IP-address/m-p/84875#M21631</guid>
      <dc:creator>wbfoxii</dc:creator>
      <dc:date>2013-04-04T16:19:59Z</dc:date>
    </item>
  </channel>
</rss>

