<?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: Help with regex for index time extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189350#M54551</link>
    <description>&lt;P&gt;Thank you so much. Can you please tell us, how can i assign the another sourcetype in the same config. because access logs are coming as syslog format and need to use appropriate sourcetype to get the field values automatically (access_combined_wcookie).&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 17:22:49 GMT</pubDate>
    <dc:creator>dhavamanis</dc:creator>
    <dc:date>2020-09-28T17:22:49Z</dc:date>
    <item>
      <title>Help with regex for index time extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189348#M54549</link>
      <description>&lt;P&gt;Can you please help us with the REGEX to extract "varnishnsca" from the log below during the indexing time to assign the _MetaData:Index. Also provide some more info how can i figure out a regex myself if any other extraction is needed.&lt;/P&gt;

&lt;P&gt;varnishncsa bal-8079 1.1.1.1 - - [20/Aug/2014:20:42:48 +0000] "HEAD &lt;A href="http://test.com/test"&gt;http://test.com/test&lt;/A&gt; HTTP/1.1" 200 0 "-" "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15" 5.049910307 miss miss request_id="v-8be63a04-28aa-11e4-9a2d-22000a1e84a4" "-"&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2014 20:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189348#M54549</guid>
      <dc:creator>dhavamanis</dc:creator>
      <dc:date>2014-08-20T20:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex for index time extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189349#M54550</link>
      <description>&lt;P&gt;You should probably have a look at this section of the docs; &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.3/Data/Advancedsourcetypeoverrides"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.3/Data/Advancedsourcetypeoverrides&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;It deals with sourcetypes and hosts, but you could just as easily use the method to rewrite the index.&lt;/P&gt;

&lt;P&gt;If your events normally go to the index 'blah' and you just want to re-route the 'varnishncsa' you'd do it like this;&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///path/to/file]
index=blah
sourcetype=bob
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[bob]
TRANSFORMS-chidx = reroute_varnish
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[reroute_varnish]
REGEX = ^varnishncsa
FORMAT = varnishncsa
DEST_KEY = _MetaData:Index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or you could do it dynamically, i.e. re-route all events to an index that matches the first word/string in each event. Just make sure that the indexes actually exist first - they will not be dynamically created;&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[bob]
TRANSFORMS-chidx = dyn_idx
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[dyn_idx]
REGEX = ^(\S+)\s*
FORMAT = $1
DEST_KEY = _MetaData:Index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Haven't tried the last alternative, since that can be slightly unpredictable.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;So if the data is coming in via syslog, I guess you should do it in inputs.conf;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[udp://514]
sourcetype=access_combined_wcookie
index=blah
connection_host= ip OR dns. see the docs.
no_appending_timestamp = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is assuming that you don't have other types of data coming in via that port. In that case you configure Splunk to listen on a dedicated port just for this traffic (if you can configure your web servers to send to e.g. udp:10514).&lt;/P&gt;

&lt;P&gt;In props.conf you call for transformation;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[access_combined_wcookie]
TRANSFORMS-set_index = awc_change_index
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and in transforms.conf you do the REGEX, FORMAT and DEST_KEY as discussed above.&lt;/P&gt;

&lt;P&gt;See &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.3/Admin/Inputsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.3/Admin/Inputsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2014 21:40:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189349#M54550</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-08-20T21:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex for index time extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189350#M54551</link>
      <description>&lt;P&gt;Thank you so much. Can you please tell us, how can i assign the another sourcetype in the same config. because access logs are coming as syslog format and need to use appropriate sourcetype to get the field values automatically (access_combined_wcookie).&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189350#M54551</guid>
      <dc:creator>dhavamanis</dc:creator>
      <dc:date>2020-09-28T17:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex for index time extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189351#M54552</link>
      <description>&lt;P&gt;see update above. /k&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 10:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-for-index-time-extraction/m-p/189351#M54552</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2014-08-22T10:04:51Z</dc:date>
    </item>
  </channel>
</rss>

