<?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: How to configure dynamic index for Splunk Universal Forwarder in a VMware Horizon Instant Clones image in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-configure-dynamic-index-for-Splunk-Universal-Forwarder-in/m-p/479432#M82265</link>
    <description>&lt;P&gt;Took me a while, but I figured this one out. For anyone else who is crazy enough to try this setup:&lt;/P&gt;

&lt;P&gt;I made use of a lesser-documented feature of VMware Horizon by using the desktop pool options "Post-Synchronization Script name:" and "Post-Synchronization Script parameters:". I wasn't able to find a definitive answer on what type of script that was meant for, or what parameter options are available, but it will successfully kick off a windows batch file as long as you give it a full local path to a batch file stored on the "Gold image" (C:\startup-script.bat), and the parameter I gave was "p1" (from the example given below the text box). &lt;/P&gt;

&lt;P&gt;For the Splunk Universal Forwarder, I did clone prep the Gold Image with the "splunk.exe clone-prep-clear-config" command, which left the inputs.conf file containing only the "[default]" header. The script I wrote to configure the VMs as described above was as follows:&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;@echo off&lt;/P&gt;

&lt;P&gt;REM #manually enable and start the splunk forwarder to get GUID and hostname&lt;BR /&gt;
sc config splunkforwarder=demand&lt;BR /&gt;
start /wait sc start splunkforwarder&lt;/P&gt;

&lt;P&gt;REM #disable splunk forwarder again and stop the service&lt;BR /&gt;
sc config splunkforwarder=disabled&lt;BR /&gt;
start /wait sc stop splunkforwarder&lt;/P&gt;

&lt;P&gt;REM #determine current host name&lt;BR /&gt;
for /f "tokens=*" %%g in ('hostname') do set NAME=%%g&lt;/P&gt;

&lt;P&gt;REM #chop the two numbers and dash off the end of the name&lt;BR /&gt;
set SHORTNAME=%NAME:~0,-3%&lt;/P&gt;

&lt;P&gt;REM #ensure the name variable is lowercase&lt;BR /&gt;
CALL :LoCase SHORTNAME&lt;/P&gt;

&lt;P&gt;REM #add the dynamic index name to the inputs file&lt;BR /&gt;
echo index = %SHORTNAME% &amp;gt;&amp;gt; "C:\Program Files\SplunkUniversalForwarder\etc\system\local\inputs.conf"&lt;/P&gt;

&lt;P&gt;REM #clear the windows logs so data is not duplicated&lt;BR /&gt;
wevtutil.exe cl Application&lt;BR /&gt;
wevtutil.exe cl System&lt;BR /&gt;
wevtutil.exe cl Security&lt;BR /&gt;
wevtutil.exe cl Setup&lt;/P&gt;

&lt;P&gt;REM #start the Splunk forwarder&lt;BR /&gt;
sc config splunkforwarder=auto&lt;BR /&gt;
start /wait sc start splunkforwarder&lt;BR /&gt;
GOTO eof&lt;/P&gt;

&lt;P&gt;:LoCase&lt;BR /&gt;
REM #function to make variables lowercase&lt;BR /&gt;
if not defined %~1 exit /b&lt;BR /&gt;
for %%a in ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") do (&lt;BR /&gt;
    call set %~1=%%%~1:%%~a%%&lt;BR /&gt;
)&lt;BR /&gt;
exit /b&lt;/P&gt;

&lt;P&gt;:eof&lt;BR /&gt;
REM #create a marker text file to indicate the script ran&lt;BR /&gt;
echo Splunk Index configuration script completed on %date% %time% &amp;gt;&amp;gt; "C:\Program Files\SplunkUniversalForwarder\etc\system\local\ScriptTime.txt"&lt;BR /&gt;
exit&lt;/P&gt;</description>
    <pubDate>Thu, 30 Apr 2020 11:35:01 GMT</pubDate>
    <dc:creator>pkt73194</dc:creator>
    <dc:date>2020-04-30T11:35:01Z</dc:date>
    <item>
      <title>How to configure dynamic index for Splunk Universal Forwarder in a VMware Horizon Instant Clones image</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-configure-dynamic-index-for-Splunk-Universal-Forwarder-in/m-p/479431#M82264</link>
      <description>&lt;P&gt;We are using a Horizon View 7 connection server to manage desktop virtual machines in multiple domains. We are using a single-instance Splunk Enterprise Server, with Splunk Universal Forwarders sending the data. All Horizon desktop pools are using Instant Clones method and are all based on snapshots of a single "Gold Image". The desktop pools have different naming conventions, but the VMs are named with consistent prefixes within their own pools. For example:&lt;/P&gt;

&lt;P&gt;devel-01, devel-02, etc.    for the "devel" pool in the "devel" domain&lt;BR /&gt;
prod-01, prod-02, etc.      for the "prod" pool in the "prod" domain&lt;/P&gt;

&lt;P&gt;For all other applications, this has been a great way to reduce administrative overhead, but Splunk Universal Forwarder is giving me fits. I need both the hostname AND the index to be dynamic. I have tried configuring the Gold Image with the "splunk clone-prep-clear-config" command, but that only affects hostname. I want these desktops to send data to pools specifically for their domains. Basically, I want to end up with an $SPLUNK_HOME/etc/system/local/inputs.conf that dynamically assigns the host name and index values based on which desktop it is running on. Something that looks like:&lt;/P&gt;

&lt;P&gt;[default]&lt;BR /&gt;
host = &lt;EM&gt;domain-number&lt;/EM&gt;&lt;BR /&gt;
index = &lt;EM&gt;domain&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Can the Splunk Universal Forwarder be incorporated into a clone image in this manner?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 15:45:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-configure-dynamic-index-for-Splunk-Universal-Forwarder-in/m-p/479431#M82264</guid>
      <dc:creator>pkt73194</dc:creator>
      <dc:date>2020-04-22T15:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure dynamic index for Splunk Universal Forwarder in a VMware Horizon Instant Clones image</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-configure-dynamic-index-for-Splunk-Universal-Forwarder-in/m-p/479432#M82265</link>
      <description>&lt;P&gt;Took me a while, but I figured this one out. For anyone else who is crazy enough to try this setup:&lt;/P&gt;

&lt;P&gt;I made use of a lesser-documented feature of VMware Horizon by using the desktop pool options "Post-Synchronization Script name:" and "Post-Synchronization Script parameters:". I wasn't able to find a definitive answer on what type of script that was meant for, or what parameter options are available, but it will successfully kick off a windows batch file as long as you give it a full local path to a batch file stored on the "Gold image" (C:\startup-script.bat), and the parameter I gave was "p1" (from the example given below the text box). &lt;/P&gt;

&lt;P&gt;For the Splunk Universal Forwarder, I did clone prep the Gold Image with the "splunk.exe clone-prep-clear-config" command, which left the inputs.conf file containing only the "[default]" header. The script I wrote to configure the VMs as described above was as follows:&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;@echo off&lt;/P&gt;

&lt;P&gt;REM #manually enable and start the splunk forwarder to get GUID and hostname&lt;BR /&gt;
sc config splunkforwarder=demand&lt;BR /&gt;
start /wait sc start splunkforwarder&lt;/P&gt;

&lt;P&gt;REM #disable splunk forwarder again and stop the service&lt;BR /&gt;
sc config splunkforwarder=disabled&lt;BR /&gt;
start /wait sc stop splunkforwarder&lt;/P&gt;

&lt;P&gt;REM #determine current host name&lt;BR /&gt;
for /f "tokens=*" %%g in ('hostname') do set NAME=%%g&lt;/P&gt;

&lt;P&gt;REM #chop the two numbers and dash off the end of the name&lt;BR /&gt;
set SHORTNAME=%NAME:~0,-3%&lt;/P&gt;

&lt;P&gt;REM #ensure the name variable is lowercase&lt;BR /&gt;
CALL :LoCase SHORTNAME&lt;/P&gt;

&lt;P&gt;REM #add the dynamic index name to the inputs file&lt;BR /&gt;
echo index = %SHORTNAME% &amp;gt;&amp;gt; "C:\Program Files\SplunkUniversalForwarder\etc\system\local\inputs.conf"&lt;/P&gt;

&lt;P&gt;REM #clear the windows logs so data is not duplicated&lt;BR /&gt;
wevtutil.exe cl Application&lt;BR /&gt;
wevtutil.exe cl System&lt;BR /&gt;
wevtutil.exe cl Security&lt;BR /&gt;
wevtutil.exe cl Setup&lt;/P&gt;

&lt;P&gt;REM #start the Splunk forwarder&lt;BR /&gt;
sc config splunkforwarder=auto&lt;BR /&gt;
start /wait sc start splunkforwarder&lt;BR /&gt;
GOTO eof&lt;/P&gt;

&lt;P&gt;:LoCase&lt;BR /&gt;
REM #function to make variables lowercase&lt;BR /&gt;
if not defined %~1 exit /b&lt;BR /&gt;
for %%a in ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") do (&lt;BR /&gt;
    call set %~1=%%%~1:%%~a%%&lt;BR /&gt;
)&lt;BR /&gt;
exit /b&lt;/P&gt;

&lt;P&gt;:eof&lt;BR /&gt;
REM #create a marker text file to indicate the script ran&lt;BR /&gt;
echo Splunk Index configuration script completed on %date% %time% &amp;gt;&amp;gt; "C:\Program Files\SplunkUniversalForwarder\etc\system\local\ScriptTime.txt"&lt;BR /&gt;
exit&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2020 11:35:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-configure-dynamic-index-for-Splunk-Universal-Forwarder-in/m-p/479432#M82265</guid>
      <dc:creator>pkt73194</dc:creator>
      <dc:date>2020-04-30T11:35:01Z</dc:date>
    </item>
  </channel>
</rss>

