Getting Data In

How to use env variables usage in inputs.conf?

damucka
Builder

Hello,

I would like to use the Unix/Windows env variables in my inputs.conf, e.g. like below:

...
### App server
# 1) dev_*
[monitor:///usr/sap/$SAPSYSTEMNAME/$INSTANCE/work/dev_*]
index=mlbso
disabled=false
interval=15
sourcetype=$SAPSYSTEMNAME_abaptraces
blacklist = dev_icf
...

So, for the above I think that the monitor path definition with the $SAPSYSTEMNAME and $INSTANCE should be fine, but I also want to put it into a system-dependent sourcetype, here ($SAPSYSTEMNAME)_abaptraces and because of the concatenation I guess it will not be properly recognized.
How would I do this correct to get it into my ABC_abaptraces sourcetype?

Kind Regards,
Kamil

0 Karma

jeffland
SplunkTrust
SplunkTrust

I don't think there's a way to do what you're trying to do in splunk .conf files. I would question your use case though: a sourcetype usually shouldn't contain a variable. Most knowledge objects are tied to sourcetype, so it should be a fixed value. Why do you need a sourcetype per host, what is the goal here? You already have the field host to distinguish your hosts. The idea behind a sourcetype is that is independent of host and source.

On a side note, if you haven't encountered it yet, you might want to check out splunk-launch.conf for setting custom variables, though that's not going to help you in this case.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...