Getting Data In

Environment variable in scripted input relative to App directory

FRoth
Contributor

I provide an App that uses an executable on Windows systems to generate some data. This program is located in the bin directory of my App named "TA-myapp". In the inputs.conf I set a scripted input that executes the program and indexes the output.

[script://$SPLUNK_HOME/etc/apps/TA-myapp/bin/evaluator.exe]

My problem is that our customer wants to deploy different versions of our app with different settings. So he renames myapp to myapp1 and myapp2 ... and so on.

Is there a environment variable that references the App home directory so that I could use that variable to configure an input like this:

[script://$APP_HOME/bin/evaluator.exe]

I am using $APP_HOME in that example because I've found references in different splunk developer documentation pages but it doesn't work. The splunkd.log states:

ERROR FrameworkUtils - Incorrect path to script: \$APP_HOME\bin\evaluator.exe.  Script must be located inside $SPLUNK_HOME\bin\scripts.

BonMot
Explorer

Splunk does not actually make environment variables available inside .conf files, but you CAN use " . " to represent the app path like so:

[script://.\bin\evaluator.exe]
0 Karma

thambisetty
SplunkTrust
SplunkTrust

Hi,

You can try below :

you can run below command :

C:\Program Files\Splunk\bin>splunk envvars > setSplunkEnv.bat

it will create file setSplunkEnv.bat under C:\Program Files\Splunk\bin with below content:

SET Path=C:\Program Files\Splunk\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Skype\Phone\;C:\Users\balaji\AppData\Local\Microsoft\WindowsApps
SET HOSTNAME=balu-pc
SET SPLUNK_HOME=C:\Program Files\Splunk
SET SPLUNK_DB=C:\Program Files\Splunk\var\lib\splunk
SET SPLUNK_ETC=C:\Program Files\Splunk\etc
SET RANDFILE=C:\Program Files\Splunk\var\run.rnd
SET SPLUNK_SERVER_NAME=Splunkd
SET SPLUNK_WEB_NAME=splunkweb
SET PYTHONPATH=C:\Program Files\Splunk\bin;C:\Program Files\Splunk\Python-2.7\Lib\site-packages\win32;C:\Program Files\Splunk\Python-2.7\Lib\site-packages;C:\Program Files\Splunk\Python-2.7\Lib
SET PYTHONHASHSEED=random
SET NODE_PATH=C:\Program Files\Splunk\lib\node_modules
SET OPENSSL_CONF=C:\Program Files\Splunk\openssl.cnf
SET LDAPCONF=C:\Program Files\Splunk\etc\openldap\ldap.conf

you can add new line to the content of file like below:

SET APP_HOME=C:\Program Files\Splunk\etc\apps\myapp

you need to change myapp to new name when ever you deployed new app to apps.

————————————
If this helps, give a like below.
0 Karma

hardikJsheth
Motivator

No there isn't anything like $APP_HOME.

Have you considered using modular input instead of scripted input as it provides more control with multiple configurations.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...