<?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 question for multiple matching fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/host-regex-question-for-multiple-matching-fields/m-p/36713#M8163</link>
    <description>&lt;P&gt;You can't do this with the &lt;CODE&gt;host_regex&lt;/CODE&gt; shortcut.  It only groks the one capture group, and doesn't give you a good way to "filter out" USELESSWORD.&lt;/P&gt;

&lt;P&gt;You should be able to do this in the config files though.&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
TRANSFORMS-host=my_awesome_host_transform
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_awesome_host_transform]
SOURCE_KEY = MetaData:Source
DEST_KEY = MetaData:Host
REGEX = .*/(FIRST01)_USELESSWORD_(SECOND01)_
FORMAT = host::$1$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 19 Dec 2011 15:42:00 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2011-12-19T15:42:00Z</dc:date>
    <item>
      <title>host_regex question for multiple matching fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/host-regex-question-for-multiple-matching-fields/m-p/36712#M8162</link>
      <description>&lt;P&gt;I am trying to set my host name equal to part of the file name with a regex (regular expression) and I am a regex novice.&lt;/P&gt;

&lt;P&gt;The filename is &lt;EM&gt;FIRST01_USELESSWORD_SECOND01_YEAR_MONTH_DAY.log&lt;/EM&gt;. I want the host name to be &lt;STRONG&gt;FIRST01SECOND01&lt;/STRONG&gt;. I can get a simple regex to pull out both of the fields with a (FIRST\d+)\w+(SECOND\d+)_ . I even tried (FIRST\d+|SECOND\d+)_ but I still only get the &lt;STRONG&gt;FIRST\d+&lt;/STRONG&gt; as the host name.&lt;/P&gt;

&lt;P&gt;I have a second file that is &lt;EM&gt;FIRST_USELESSWORD_1_YEAR_MONTH_DAY.log&lt;/EM&gt; that I am trying to the host name to be &lt;STRONG&gt;FIRST1&lt;/STRONG&gt;, but am having the same issue. I don't know if a lookback or lookahead is needed. Basically, I am just at loss because of my lack of regex experience.&lt;/P&gt;

&lt;P&gt;Any help is appreciated. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/host-regex-question-for-multiple-matching-fields/m-p/36712#M8162</guid>
      <dc:creator>ianathompson</dc:creator>
      <dc:date>2020-09-28T10:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: host_regex question for multiple matching fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/host-regex-question-for-multiple-matching-fields/m-p/36713#M8163</link>
      <description>&lt;P&gt;You can't do this with the &lt;CODE&gt;host_regex&lt;/CODE&gt; shortcut.  It only groks the one capture group, and doesn't give you a good way to "filter out" USELESSWORD.&lt;/P&gt;

&lt;P&gt;You should be able to do this in the config files though.&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
TRANSFORMS-host=my_awesome_host_transform
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_awesome_host_transform]
SOURCE_KEY = MetaData:Source
DEST_KEY = MetaData:Host
REGEX = .*/(FIRST01)_USELESSWORD_(SECOND01)_
FORMAT = host::$1$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Dec 2011 15:42:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/host-regex-question-for-multiple-matching-fields/m-p/36713#M8163</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-12-19T15:42:00Z</dc:date>
    </item>
  </channel>
</rss>

