All Apps and Add-ons

How do I get data from app.conf?

robertlight
Path Finder

I am trying to get data out of my app.conf file in /local/app.conf or from /default/app.conf

I tried using:

splunk.clilib.cli_common.getConfKeyValue("app","package","id")

but this ultimately results in a call to btool:

./splunk cmd btool app list

which returns a merged form of app.conf which is not relevant to my particular app.

I would have to issue the command:

./splunk cmd btool --app=myAppNameHere app list

to get the data for my particular app.

But since I'm trying to get the value for "id"... which is my app's name... why would I use my app's name to get my app's name??

So now I am left with the question... how do I get my app's name?

Tags (2)
0 Karma

Damien_Dallimor
Ultra Champion

Can you describe your use case a bit more ?

Are you trying to access the app.conf file from a standalone program ? some javascript in a dashboard ? a custom search command ?

Conf files can be read via the Splunk REST API :

http://docs.splunk.com/Documentation/Splunk/6.2.1/RESTREF/RESTconfExamples#configs.2Fconf-.7Bfile.7D...

Example :

curl -k -u admin:pass https://localhost:8089/servicesNS/admin/yourapp/configs/conf-app 

And you can invoke this REST endpoint in a variety of ways depending on your use case (SplunkJS functions , SDK's , splunk.entity Python class etc....)

0 Karma

robertlight
Path Finder

I am writing a custom app for splunk. Therefore I am in serverside python application code.

Yes, I know the name of my app... I could hardcode the name into my python code.

I was looking for a bit more elegant and less brittle approach to determine the name of my app other than hardcoding a string into my code.

0 Karma

Damien_Dallimor
Ultra Champion

What sort of server side python code ? custom rest endpoint ? search command ? external scripted alert ? cherrypy controller ?

Here is some code to point you in the right direction :

    import splunk.entity        
    session_key = 'your session key'
    entity = splunk.entity.getEntity('/configs/conf-app','package', namespace='yourapp', sessionKey=session_key, owner='nobody')
    app_id = entity.get('id')
0 Karma

robertlight
Path Finder

Doesn't the part:

namespace='yourapp'

require you to know the id of your app??

I'm trying to figure out the name of my app (chicken and the egg problem here).

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!

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...

Global Splunk User Group Events: May + June 2026

Your Splunk Community Awaits: Discover Upcoming User Group Events Worldwide    Staying ahead in the fast-paced ...