Splunk Search

Global Environment Vars Shared Between Scripts?

_dave_b
Communicator

Hello. Is there a way to set a global environment variable in Splunk so that it can be shared and used multiple times between scripts?

Specifically, I want to set the version number in my app.conf to a value, then re-use that value later on in the dashboard/XML page for the app.

So my app.conf would look like

[launcher]
version=[VERSION_NUM]

And the footer of my dashboard.js/xml would look like
< Dave B's App Version > < [VERSION_NUM] >

And VERSION_NUM gets defined in some other, external config file

So basically I want to be able to set VERSION_NUM once, and use it repeatedly and consistently.
A little preliminary research reveals that maybe it can be done with REST. Is there a faster way?

Thanks!

0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi _dave_b,

the easiest way to use the app version number from app.conf is to call it from the REST endpoint:

| rest /servicesNS/-/-/apps/local/ | search title="YourAppNameHere" | table title version

and use the result in your footer.

Hope this helps ...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi _dave_b,

the easiest way to use the app version number from app.conf is to call it from the REST endpoint:

| rest /servicesNS/-/-/apps/local/ | search title="YourAppNameHere" | table title version

and use the result in your footer.

Hope this helps ...

cheers, MuS

_dave_b
Communicator

Thanks MuS. That helps by pointing me towards REST, but I don't see a section in the REST API Reference Manual that shows me how to access the contents of app.conf

0 Karma

MuS
SplunkTrust
SplunkTrust

Well, this is because you're looking only at the Search Reference of the command rest but not the REST API Reference Manual and within there this is the important topic for you http://docs.splunk.com/Documentation/Splunk/6.0.3/RESTAPI/RESTapps#apps.2Flocal

cheers, MuS

0 Karma

_dave_b
Communicator

Ok! Thanks to your help, I am now able to pull the Version number straight from the app.conf file.

Now my quandry is how do I move that number from the Splunk results table that it's in into a line of html on my dashboard?

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!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...