<?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: Add Data: Input Settings: Regular expression on path/filename to create Host field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-Data-Input-Settings-Regular-expression-on-path-filename-to/m-p/134046#M36630</link>
    <description>&lt;P&gt;Based on a file location similar to /opt/input_data/albatross-b8197b6cf24c.abcd.20150208.hardata.csv&lt;/P&gt;

&lt;P&gt;You could use something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\/\S+-(?&amp;lt;host&amp;gt;.+)\.\w+\.+\S+\d+\.\w+\.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Someone can provide a neater regex but you get the idea.&lt;/P&gt;

&lt;P&gt;Doco is here : &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/Data/Setadefaulthostforaninput" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/Data/Setadefaulthostforaninput&lt;/A&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Edit inputs.conf&lt;BR /&gt;
You can set up dynamic host extraction rules by directly configuring inputs.conf.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Edit inputs.conf in $SPLUNK_HOME/etc/system/local/ or in your own custom application directory in $SPLUNK_HOME/etc/apps/. For more information on configuration files in general, see "About configuration files" in the Admin manual.&lt;/P&gt;

&lt;P&gt;Use the host_regex attribute to override the host field with a value extracted through a regular expression:&lt;/P&gt;

&lt;P&gt;[monitor://]&lt;BR /&gt;
host_regex = &lt;BR /&gt;
The regular expression extracts the host value from the filename of each input. &lt;STRONG&gt;The first capturing group of the regular expression is used as the host.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:52:51 GMT</pubDate>
    <dc:creator>Lucas_K</dc:creator>
    <dc:date>2020-09-28T18:52:51Z</dc:date>
    <item>
      <title>Add Data: Input Settings: Regular expression on path/filename to create Host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Data-Input-Settings-Regular-expression-on-path-filename-to/m-p/134045#M36629</link>
      <description>&lt;P&gt;I'm adding a CSV using the "Add Data" GUI in Splunk 6.2. When I get to the Input Settings page, I have the option to specify a "Regular expression on path" to define the Host field. However, I have not been able to find any documentation on the correct syntax.&lt;/P&gt;

&lt;P&gt;I'm not really concerned with the path of the file, so much as I am the file name in the path. So, for example, my file name is: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;albatross-b8197b6cf24c.abcd.20150208.hardata.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to extract "b8197b6cf24c" and use that as the Host name. How would I specify the regular expression to do that from the Input Settings of the GUI? &lt;/P&gt;</description>
      <pubDate>Mon, 09 Feb 2015 22:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Data-Input-Settings-Regular-expression-on-path-filename-to/m-p/134045#M36629</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2015-02-09T22:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add Data: Input Settings: Regular expression on path/filename to create Host field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-Data-Input-Settings-Regular-expression-on-path-filename-to/m-p/134046#M36630</link>
      <description>&lt;P&gt;Based on a file location similar to /opt/input_data/albatross-b8197b6cf24c.abcd.20150208.hardata.csv&lt;/P&gt;

&lt;P&gt;You could use something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\/\S+-(?&amp;lt;host&amp;gt;.+)\.\w+\.+\S+\d+\.\w+\.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Someone can provide a neater regex but you get the idea.&lt;/P&gt;

&lt;P&gt;Doco is here : &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/Data/Setadefaulthostforaninput" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/Data/Setadefaulthostforaninput&lt;/A&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Edit inputs.conf&lt;BR /&gt;
You can set up dynamic host extraction rules by directly configuring inputs.conf.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Edit inputs.conf in $SPLUNK_HOME/etc/system/local/ or in your own custom application directory in $SPLUNK_HOME/etc/apps/. For more information on configuration files in general, see "About configuration files" in the Admin manual.&lt;/P&gt;

&lt;P&gt;Use the host_regex attribute to override the host field with a value extracted through a regular expression:&lt;/P&gt;

&lt;P&gt;[monitor://]&lt;BR /&gt;
host_regex = &lt;BR /&gt;
The regular expression extracts the host value from the filename of each input. &lt;STRONG&gt;The first capturing group of the regular expression is used as the host.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:52:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-Data-Input-Settings-Regular-expression-on-path-filename-to/m-p/134046#M36630</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2020-09-28T18:52:51Z</dc:date>
    </item>
  </channel>
</rss>

