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
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...