<?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 How can I route logs to a specific index based on host/source combo? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333119#M61604</link>
    <description>&lt;P&gt;We currently have our perf and N1 environments combined and I need to route certain logs to certain indexes based on the host/source combo.  &lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
Host:  N1host.company.com&lt;BR /&gt;
Source - /var/appl/logs/company.log&lt;BR /&gt;
Source - /var/appl/logs/company_perf.log&lt;/P&gt;

&lt;P&gt;Right now, our transforms looks like this and routes all logs from this host to index=company_perf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[index-company_perf]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(&amp;lt;hostname&amp;gt;)$
DEST_KEY = _MetaData:Index
FORMAT = company_perf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I need to happen is have logs from that host, N1host, with any source that has &lt;EM&gt;perf.log&lt;/EM&gt; to go to the index=company_perf and everything else from that host go to index=company_n1.&lt;/P&gt;

&lt;P&gt;How can I modify this existing transforms to do what I need?  Or can I create a new transforms to deal with it?&lt;/P&gt;

&lt;P&gt;Can we modify the &lt;CODE&gt;SOURCE_KEY = fields:host,source&lt;/CODE&gt;?  What would the regex look like?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:21:38 GMT</pubDate>
    <dc:creator>bport15</dc:creator>
    <dc:date>2020-09-29T14:21:38Z</dc:date>
    <item>
      <title>How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333119#M61604</link>
      <description>&lt;P&gt;We currently have our perf and N1 environments combined and I need to route certain logs to certain indexes based on the host/source combo.  &lt;/P&gt;

&lt;P&gt;Example:&lt;BR /&gt;
Host:  N1host.company.com&lt;BR /&gt;
Source - /var/appl/logs/company.log&lt;BR /&gt;
Source - /var/appl/logs/company_perf.log&lt;/P&gt;

&lt;P&gt;Right now, our transforms looks like this and routes all logs from this host to index=company_perf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[index-company_perf]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(&amp;lt;hostname&amp;gt;)$
DEST_KEY = _MetaData:Index
FORMAT = company_perf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I need to happen is have logs from that host, N1host, with any source that has &lt;EM&gt;perf.log&lt;/EM&gt; to go to the index=company_perf and everything else from that host go to index=company_n1.&lt;/P&gt;

&lt;P&gt;How can I modify this existing transforms to do what I need?  Or can I create a new transforms to deal with it?&lt;/P&gt;

&lt;P&gt;Can we modify the &lt;CODE&gt;SOURCE_KEY = fields:host,source&lt;/CODE&gt;?  What would the regex look like?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333119#M61604</guid>
      <dc:creator>bport15</dc:creator>
      <dc:date>2020-09-29T14:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333120#M61605</link>
      <description>&lt;P&gt;It's probably possible to do what you want, but I think you'd be better served changing the inputs in some way to make the end result easier to accomplish.&lt;/P&gt;

&lt;P&gt;Can you (or do you already) get the hostname as part of the source path?  That would allow you to do one transform to determine host and filename to act on.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 15:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333120#M61605</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-06-01T15:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333121#M61606</link>
      <description>&lt;P&gt;You can do this by calling your transform from a source specific stanza in props.conf &lt;BR /&gt;
i.e.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/var/appl/logs/*_perf.log]
TRANSFORMS-index-company_perf = index-company_perf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [index-company_perf]
 SOURCE_KEY = MetaData:Host
 REGEX = ^host::(&amp;lt;hostname&amp;gt;)$
 DEST_KEY = _MetaData:Index
 FORMAT = company_perf
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 17:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333121#M61606</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2017-06-01T17:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333122#M61607</link>
      <description>&lt;P&gt;That's actually a good point.  I hadn't thought of that.  I'll give that a shot and report back if it worked!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 18:25:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333122#M61607</guid>
      <dc:creator>bport15</dc:creator>
      <dc:date>2017-06-01T18:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333123#M61608</link>
      <description>&lt;P&gt;Ooooh, I like this, assuming it works.  I had never considered specifying index-time transforms by source instead of sourcetype.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 18:27:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333123#M61608</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-06-01T18:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333124#M61609</link>
      <description>&lt;P&gt;So after looking at all of our current configurations, it's not our perf logs that are the problem.  It's everything else.  &lt;/P&gt;

&lt;P&gt;When we first got Splunk 4 years ago at our company, perf and N1 were combined and the vast majority of it still is.  We are routing logs to specific indexes based on hostname.  We did this because the log path for each environment is exactly the same, except for perf, and we didn't want to create several different configuration apps that contained the same log paths.  Looking back, I wish we hadn't done that, but it would take a giant effort to rework all of this at this point.&lt;/P&gt;

&lt;P&gt;Below is an example of how our current logs are, broken out by host, source and index, and a copy of our transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Host=prod source=/var/appl/logs/mobile-remote_access.log index=company_prod
Host=n1 source=/var/appl/logs/mobile-remote_access.log index=company_perf
Host=n1 source= /var/appl/logs/mobile-remote_access_perf.log index=company_perf
Host=n0 source=/var/appl/logs/mobile-remote_access.log index=company_n
Host=n2a source=/var/appl/logs/mobile-remote_access.log index=company_n2a

Transforms.conf

[index-company_prod]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(prod.[\d]+.*)$
DEST_KEY = _MetaData:Index
FORMAT = company_prod

[index-company_n]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(n0.[\d]+.*)$
DEST_KEY = _MetaData:Index
FORMAT = company_n

[index-company_n2a]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(n2a.[\d]+.*)$
DEST_KEY = _MetaData:Index
FORMAT = company_n2a

[index-company_perf]
SOURCE_KEY = MetaData:Host
REGEX = ^host::(n1.[\d]+.*)$
DEST_KEY = _MetaData:Index
FORMAT = company_perf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In case you're wondering, I have asked our developers to fix this on their end instead, which is just as difficult, if not more difficult, on their end.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 15:47:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333124#M61609</guid>
      <dc:creator>bport15</dc:creator>
      <dc:date>2017-06-12T15:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I route logs to a specific index based on host/source combo?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333125#M61610</link>
      <description>&lt;P&gt;I suppose I could modify my current transforms.conf, as suggested by masonmorales, and create a new one for our n environment, like this:&lt;/P&gt;

&lt;P&gt;Remove &lt;CODE&gt;index-company_perf&lt;/CODE&gt; from each Sourcetype within props.conf and use it on a source reference instead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[index-company_perf]
 SOURCE_KEY = MetaData:Host
 REGEX = ^host::(n1.[\d]+.*)$
 DEST_KEY = _MetaData:Index
 FORMAT = company_perf



 Props.conf
    [source::/var/appl/logs/*_perf.log]
     TRANSFORMS-index-company_perf = index-company_perf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Create a new stanza in transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[index-company_n]
 SOURCE_KEY = MetaData:Host
 REGEX = ^host::(n1.[\d]+.*)$
 DEST_KEY = _MetaData:Index
 FORMAT = company_n

Props.conf
 [my_sourcetype]
TRANSFORMS-index-company_n = index-company_n
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 15:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-route-logs-to-a-specific-index-based-on-host-source/m-p/333125#M61610</guid>
      <dc:creator>bport15</dc:creator>
      <dc:date>2017-06-12T15:57:13Z</dc:date>
    </item>
  </channel>
</rss>

