<?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: Regex to match two fields in transforms.conf in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364382#M107540</link>
    <description>&lt;P&gt;Ah ha! Yes I add the MyCustomField on the input from a Universal Forwarder. I want to set the index name based on the value in MyCustomField so maybe I can match in props.conf for the source and then pull out the value for MyCustomField to build the Index name.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::syslog]
TRANSFORMS-Index-Syslog = Set-Index-Syslog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Set-Index-Syslog]    
SOURCE_KEY = MetaData:MyCustomField    
REGEX = (.*)
DEST_KEY = _MetaData:Index
FORMAT = index-$1-Syslog
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Mar 2017 19:18:53 GMT</pubDate>
    <dc:creator>danbrook</dc:creator>
    <dc:date>2017-03-16T19:18:53Z</dc:date>
    <item>
      <title>Regex to match two fields in transforms.conf</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364378#M107536</link>
      <description>&lt;P&gt;I'm looking to match against two fields in transforms.conf. I would like to match against a customer _meta field and the source field then route to a specific index based on that. There is a good reason for me not matching on inputs.conf that I won't go into here.&lt;/P&gt;

&lt;P&gt;I would like to match&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;regex=MyCustomField::somestring&lt;/CODE&gt; AND &lt;CODE&gt;regex=source::syslog&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I'd also like to be able to test this in search before committing it to transforms.conf&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 13:06:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364378#M107536</guid>
      <dc:creator>danbrook</dc:creator>
      <dc:date>2017-03-16T13:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match two fields in transforms.conf</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364379#M107537</link>
      <description>&lt;P&gt;I assume "now matching" was supposed to be "not matching"?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:16:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364379#M107537</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-16T15:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match two fields in transforms.conf</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364380#M107538</link>
      <description>&lt;P&gt;Yes, edited.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:20:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364380#M107538</guid>
      <dc:creator>danbrook</dc:creator>
      <dc:date>2017-03-16T15:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match two fields in transforms.conf</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364381#M107539</link>
      <description>&lt;P&gt;Okay, you have to make sure that your extraction transforms are happening in the right order.  This can't really be tested in "search", so I recommend you set yourself up a sandbox instance.  &lt;/P&gt;

&lt;P&gt;There are lots of good answers on overriding metadata and sending to a new index.  But a workable final architecture is going to depend on knowing your data and your existing transforms.  &lt;/P&gt;

&lt;P&gt;1) Is MyCustomField::somestring going to occur in any source other than syslog?&lt;BR /&gt;
2) When does MyCustomField get extracted?&lt;/P&gt;

&lt;P&gt;Your new transform will need to be called and evaluated AFTER MyCustomField exists, but only for events in source=syslog.  &lt;/P&gt;

&lt;P&gt;If you can make that happen, then the stanza would look something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  [index_reset_for_MyCustomField]
  SOURCE_KEY = MyCustomField
  DEST_KEY =  _MetaData:index
  REGEX = somestring
  FORMAT = mynewindexname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you CANNOT determine an order where that would happen, then you might have to do place a ricochet shot.  You can't really PROGRAM in a stanza, or concatenate two fields.  &lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 18:22:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364381#M107539</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-16T18:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match two fields in transforms.conf</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364382#M107540</link>
      <description>&lt;P&gt;Ah ha! Yes I add the MyCustomField on the input from a Universal Forwarder. I want to set the index name based on the value in MyCustomField so maybe I can match in props.conf for the source and then pull out the value for MyCustomField to build the Index name.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::syslog]
TRANSFORMS-Index-Syslog = Set-Index-Syslog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Set-Index-Syslog]    
SOURCE_KEY = MetaData:MyCustomField    
REGEX = (.*)
DEST_KEY = _MetaData:Index
FORMAT = index-$1-Syslog
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:18:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364382#M107540</guid>
      <dc:creator>danbrook</dc:creator>
      <dc:date>2017-03-16T19:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Regex to match two fields in transforms.conf</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364383#M107541</link>
      <description>&lt;P&gt;The two requirements for that to work are (1) MyCustomField must be extracted before the  [source::syslog] stanza is reached, and (2) the value of MyCustomField must have been set to whatever you want sandwiched into the index name.&lt;/P&gt;

&lt;P&gt;I would probably use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; REGEX = (.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;since the other would match an empty (but not a null) field.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 23:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-to-match-two-fields-in-transforms-conf/m-p/364383#M107541</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-16T23:53:00Z</dc:date>
    </item>
  </channel>
</rss>

