<?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: How to extract a value in a log and use it as hostname in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-a-value-in-a-log-and-use-it-as-hostname/m-p/528506#M89097</link>
    <description>&lt;P&gt;I have the solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;first I've changed up my regex and deleted the SOURCE_KEY in transforms.conf:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[changehost]
DEST_KEY = MetaData:Host
REGEX = [\d\w\s]{7}.[\d\w\s]{3}.\w*.\w*(?=\sASM)
FORMAT = host::$1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;this regex is more clear in what it should do and matched the value perfectly. Given the documentation here:&amp;nbsp;&lt;A title="here" href="https://docs.splunk.com/Documentation/Splunk/8.0.6/Data/Overridedefaulthostassignments" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.6/Data/Overridedefaulthostassignments&lt;/A&gt;&amp;nbsp; I don't need a SOURCE_KEY and the FORMAT should be host::$1 . &lt;EM&gt;&lt;STRONG&gt;$1&lt;/STRONG&gt; is refering to the regex while &lt;STRONG&gt;host&lt;/STRONG&gt; tells the FORMAT to put the value into the host field.&lt;/EM&gt; (If this explanation is off - please correct me).&lt;/P&gt;&lt;P&gt;Still I had a little problem. when trying to input the data the hostvalue was suddenly $1 not the value I tried to extract. the reason was that I forgot to encapsulate my regex in () so it'll become a capture group. so the new regex was :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;([\d\w\s]{7}.[\d\w\s]{3}.\w*.\w*)(?=\sASM)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it worked like a charm.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, since my value was right before the characters ASM I used a positive lookahead&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class="_1xGnW"&gt;(?=&lt;/SPAN&gt;&lt;SPAN class="_13Ps7"&gt;\s&lt;/SPAN&gt;&lt;SPAN class=""&gt;ASM&lt;/SPAN&gt;&lt;SPAN class="_1xGnW"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Nov 2020 10:15:50 GMT</pubDate>
    <dc:creator>avoelk</dc:creator>
    <dc:date>2020-11-09T10:15:50Z</dc:date>
    <item>
      <title>How to extract a value in a log and use it as hostname</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-a-value-in-a-log-and-use-it-as-hostname/m-p/528442#M89092</link>
      <description>&lt;P&gt;I've tried using props.conf.spec and transforms.conf.spec and some regex to extract a value from a logfile in order to use it as my hostname value. I see that with my regex I can extract the given value but I have two problems:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.) when I use the gui to get data in I can only choose a given value for hostname pre indexing or use regex only for the path in which my logfile lies. When I put in my tested regex in the hostname field it ofc doesn't work.&amp;nbsp; So I guess I first have to set up the sourcetype in props.conf and configure the extraction in transforms.conf&lt;/P&gt;&lt;P&gt;2.) I can't seem to find an explanation on how to configure the extraction correctly. like I said the regex seems okay but in transforms I seem to need the following fields which I don't know how to use:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SOURCE_KEY&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DEST_KEY&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FORMAT&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In the Logfile it looks similar to that&amp;nbsp; (the host value is "DC1ASM1.dc1.greendotcorp.com"):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sep 20 11:13:36 10.50.3.100 Sep 20 11:13:33 DC1ASM1.dc1.greendotcorp.com ASM:"MONEYPAK_WEBAPP","MONEYPAK_CLASS","Blocked","Attack signature detected","4523972057501657341","207.154.35.240","GET /Content/Images/img_logo04_module02.gif HTTP/1.1\r\nHost:...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mostly it's this host name. and I want to extract&amp;nbsp; and use it as hostname at indextime.&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is what I did so far:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;props.conf:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[f5asm]
BREAK_ONLY_BEFORE = \w+ \d+ \d+:\d+:\d+ \d+
BREAK_ONLY_BEFORE_DATE =
DATETIME_CONFIG =
LINE_BREAKER = \w+ \d+ \d+:\d+:\d+ \d+
NO_BINARY_CHECK = true
TIME_FORMAT = %b %d %H:%M:%S
TIME_PREFIX = \d+.\d+.\d+.\d+
category = Custom
disabled = false
pulldown_type = true
TRANSFORMS-hostname = changehost&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[changehost]
DEST_KEY = MetaData:Host
SOURCE_KEY = MetaData:Host
REGEX = ([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6} +?(?=ASM)FORMAT = host::$1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm fairly certain that I have to change up something in transforms.conf but I can't seem to find an answer. any ideas how to set up the &lt;EM&gt;FORMAT, DEST_KEY and SOURCE_KEY&lt;/EM&gt; correctly in that case?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 08:57:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-a-value-in-a-log-and-use-it-as-hostname/m-p/528442#M89092</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2020-11-09T08:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a value in a log and use it as hostname</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-a-value-in-a-log-and-use-it-as-hostname/m-p/528506#M89097</link>
      <description>&lt;P&gt;I have the solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;first I've changed up my regex and deleted the SOURCE_KEY in transforms.conf:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[changehost]
DEST_KEY = MetaData:Host
REGEX = [\d\w\s]{7}.[\d\w\s]{3}.\w*.\w*(?=\sASM)
FORMAT = host::$1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;this regex is more clear in what it should do and matched the value perfectly. Given the documentation here:&amp;nbsp;&lt;A title="here" href="https://docs.splunk.com/Documentation/Splunk/8.0.6/Data/Overridedefaulthostassignments" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.0.6/Data/Overridedefaulthostassignments&lt;/A&gt;&amp;nbsp; I don't need a SOURCE_KEY and the FORMAT should be host::$1 . &lt;EM&gt;&lt;STRONG&gt;$1&lt;/STRONG&gt; is refering to the regex while &lt;STRONG&gt;host&lt;/STRONG&gt; tells the FORMAT to put the value into the host field.&lt;/EM&gt; (If this explanation is off - please correct me).&lt;/P&gt;&lt;P&gt;Still I had a little problem. when trying to input the data the hostvalue was suddenly $1 not the value I tried to extract. the reason was that I forgot to encapsulate my regex in () so it'll become a capture group. so the new regex was :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;([\d\w\s]{7}.[\d\w\s]{3}.\w*.\w*)(?=\sASM)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it worked like a charm.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, since my value was right before the characters ASM I used a positive lookahead&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class="_1xGnW"&gt;(?=&lt;/SPAN&gt;&lt;SPAN class="_13Ps7"&gt;\s&lt;/SPAN&gt;&lt;SPAN class=""&gt;ASM&lt;/SPAN&gt;&lt;SPAN class="_1xGnW"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 10:15:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-a-value-in-a-log-and-use-it-as-hostname/m-p/528506#M89097</guid>
      <dc:creator>avoelk</dc:creator>
      <dc:date>2020-11-09T10:15:50Z</dc:date>
    </item>
  </channel>
</rss>

