<?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: Routing to index based on Regex extraction in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342448#M63080</link>
    <description>&lt;P&gt;Hi @somesoni2, yes, just a typo when typing the question. Have edited question.&lt;BR /&gt;
Is it possible to remove spaces in the capture group?&lt;BR /&gt;
I shall give this a try.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 15:12:29 GMT</pubDate>
    <dc:creator>Tim_1</dc:creator>
    <dc:date>2017-09-19T15:12:29Z</dc:date>
    <item>
      <title>Routing to index based on Regex extraction</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342445#M63077</link>
      <description>&lt;P&gt;Hi all, &lt;/P&gt;

&lt;P&gt;I want to know if it is possible to route data to different indexes based on the value of a regex dynamically.&lt;/P&gt;

&lt;P&gt;Example data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Department:Sec Team, Value=3, Date=12/12/2009
Department:Sales, Value=1, Date=12/03/2010
Department:Other, Value=23, Date=03/02/2011
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know you can hard code the routing like such in transforms.conf: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[route1]
REGEX = "Department:Sec Team"
DEST KEY = _MetaData:Index
FORMAT = index_sec

[route2]
REGEX = "Department:Sales"
DEST KEY = _MetaData:Index
FORMAT = index_sales

[route3]
REGEX = "Department:Other"
DEST KEY = _MetaData:Index
FORMAT = index_other
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, this can become very messy as more and more departments are created (for example).&lt;BR /&gt;
Is it possible to do something like such?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[route]
REGEX = "Department:&amp;lt;value&amp;gt;"
DEST KEY = _MetaData:Index
FORMAT = index_&amp;lt;value&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am using Splunk Enterprise 6.4.2&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 14:25:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342445#M63077</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-19T14:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Routing to index based on Regex extraction</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342446#M63078</link>
      <description>&lt;P&gt;Hi there Tim, Im afraid that this is not possible.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 15:03:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342446#M63078</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-09-19T15:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Routing to index based on Regex extraction</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342447#M63079</link>
      <description>&lt;P&gt;First, just want to confirm if there is typo in &lt;CODE&gt;_Metadata:Index&lt;/CODE&gt; as it should be &lt;CODE&gt;_MetaData:Index&lt;/CODE&gt;. Second, you can have captured group in REGEX used in FORAMT like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[route]
 REGEX = "Department:(\S+)"
 DEST KEY = _MetaData:Index
 FORMAT = index_$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since there are restrictions in names of index (no spaces or special characters), make sure your capturing group regex is not capturing any of that.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 15:04:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342447#M63079</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-19T15:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Routing to index based on Regex extraction</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342448#M63080</link>
      <description>&lt;P&gt;Hi @somesoni2, yes, just a typo when typing the question. Have edited question.&lt;BR /&gt;
Is it possible to remove spaces in the capture group?&lt;BR /&gt;
I shall give this a try.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 15:12:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342448#M63080</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-19T15:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Routing to index based on Regex extraction</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342449#M63081</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Somesoni2&lt;/STRONG&gt;'s answer will set the index name to have the uppercase department name (e.g. &lt;CODE&gt;index_Sales&lt;/CODE&gt; instead of &lt;CODE&gt;index_sales&lt;/CODE&gt;). Are you needing to use the lowercase? I'm not sure if that can be done. The &lt;CODE&gt;EVAL&lt;/CODE&gt; parameter of &lt;CODE&gt;props.conf&lt;/CODE&gt; is where I would do that, and it comes after the TRANSFORMS stuff from the &lt;CODE&gt;transforms.conf&lt;/CODE&gt; in the index data pipeline, so you could not use that method to lowercase the department. The same may &lt;STRONG&gt;not&lt;/STRONG&gt; be said for the removal of spaces in the department name. You &lt;STRONG&gt;can&lt;/STRONG&gt; use a &lt;CODE&gt;SEDCMD&lt;/CODE&gt; in &lt;CODE&gt;props.conf&lt;/CODE&gt; and then do the assignment of the index in the &lt;CODE&gt;transforms.conf&lt;/CODE&gt;, but I believe that your &lt;CODE&gt;_raw&lt;/CODE&gt; data would change. So you could do something like &lt;CODE&gt;index_SecTeam&lt;/CODE&gt;. You could also do it in the REGEX with something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = "Department:(\S+)\s*(\S*),"
FORMAT = index_$1$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Make sure you have department indexes all created for data that will directed to the various indexes. You don't want to get lots of error messages saying you are sending to non-existent indexes whenever a new department name shows up in the logs.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 21:06:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342449#M63081</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-09-19T21:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Routing to index based on Regex extraction</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342450#M63082</link>
      <description>&lt;P&gt;@cpetterborg, thanks for the details reply, shall try your suggestions.&lt;/P&gt;

&lt;P&gt;Also, I'm assuming that it is impossible to have a dynamic number of capture groups? What I mean by this is that if the value for Department has &lt;CODE&gt;n&lt;/CODE&gt; number of white spaces, you will need to specify in the REGEX that it has &lt;CODE&gt;n&lt;/CODE&gt; white spaces. &lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 08:53:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Routing-to-index-based-on-Regex-extraction/m-p/342450#M63082</guid>
      <dc:creator>Tim_1</dc:creator>
      <dc:date>2017-09-20T08:53:54Z</dc:date>
    </item>
  </channel>
</rss>

