Splunk Dev

Splunk Python conf file read/write

arun_kant_sharm
Path Finder

Hi Experts,

For an app creation, I need to create my own .conf file. Please inform me How I create a custom conf file, and how I read and write data in that conf file using Python.
Please inform me where I can learn Splunk Python packages, better if it in present in any youtube channel.

Labels (1)
0 Karma

gaurav_maniar
Builder

hi Arun,

Your question is very broad, but I will try to answer it as specific as possible.

Create Custom .conf file
- You can include setup.xml in your application. Using it you can create your custom conf and modify it.
- It will be accessible to users from "Manage Apps" page.
- Setup page is useful when you want to customize an app for a particular usage
- You can update the values using the setup page. The values will be saved in local directory of the app
- https://dev.splunk.com/enterprise/docs/developapps/setuppage

Now, to read the custom conf value, use the below code with your splunk python script,

from splunk.clilib import cli_common as cli
.
...
.
cfg = cli.getConfStanza('custom_conf_file_name','custom_stanza')
print cfg.get('parameter')

Let me know if you have any queries.

0 Karma

mcederhage_splu
Splunk Employee
Splunk Employee
0 Karma
Get Updates on the Splunk Community!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...