<?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 Parsing a field, how can I tell if the value is an IP or a hostname (string)? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228160#M44457</link>
    <description>&lt;P&gt;If I parse out a field, how can I tell if the value is an IP or a hostname?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp host error: Auth fail user1 from 1.2.3.4
timestamp host error: Auth fail user2 from host.machine.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;While it's easy to put that last info into a field called source,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-user,source = error: Auth fail (?&amp;lt;user&amp;gt;.+?) from (?&amp;lt;source&amp;gt;.+) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to find out if the source is an IP or a hostname.&lt;/P&gt;

&lt;P&gt;What is the syntax in props.conf to do that?&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2016 17:33:49 GMT</pubDate>
    <dc:creator>reswob4</dc:creator>
    <dc:date>2016-04-29T17:33:49Z</dc:date>
    <item>
      <title>Parsing a field, how can I tell if the value is an IP or a hostname (string)?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228160#M44457</link>
      <description>&lt;P&gt;If I parse out a field, how can I tell if the value is an IP or a hostname?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp host error: Auth fail user1 from 1.2.3.4
timestamp host error: Auth fail user2 from host.machine.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;While it's easy to put that last info into a field called source,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-user,source = error: Auth fail (?&amp;lt;user&amp;gt;.+?) from (?&amp;lt;source&amp;gt;.+) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to find out if the source is an IP or a hostname.&lt;/P&gt;

&lt;P&gt;What is the syntax in props.conf to do that?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:33:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228160#M44457</guid>
      <dc:creator>reswob4</dc:creator>
      <dc:date>2016-04-29T17:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a field, how can I tell if the value is an IP or a hostname (string)?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228161#M44458</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;error: Auth fail (?:(?&amp;lt;user&amp;gt;.+?) from (?&amp;lt;source_ip&amp;gt;\d+\.\d+\.\d+\.\d+)|(?&amp;lt;source_hostname&amp;gt;.+))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:44:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228161#M44458</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-29T17:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing a field, how can I tell if the value is an IP or a hostname (string)?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228162#M44459</link>
      <description>&lt;P&gt;You might be able to use alternation to optionally extract an additional field (I haven't tried this in Splunk yet, but the theory goes like this):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-user,source,ip_source = error : Auth fail (?&amp;lt;user&amp;gt;\S+) from (?&amp;lt;source&amp;gt;(?&amp;lt;ip_source&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|.+))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Yes that is an overly broad match for an ipv4 address but bear with me here)&lt;/P&gt;

&lt;P&gt;When you have an ipaddress you will have an extra field called ip_source, when you do not, you won't. So you can then test if the ip_source field is populated or null will tell you if the source is an ip address or not.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:35:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Parsing-a-field-how-can-I-tell-if-the-value-is-an-IP-or-a/m-p/228162#M44459</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2020-09-29T09:35:08Z</dc:date>
    </item>
  </channel>
</rss>

