Splunk Dev

Writing to a .conf/.json file on a search head cluster via Python

alucarddjin
Path Finder

I am trying to make an app (using Python) in which a user will select key field details that have to be saved into a settings file (json or conf) but currently when it write's it's only saving to the search head the user is currently on, no replicating across them all. 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Thanks for clarifying.  SHCs do not replicate every file.  To see what is replicated, visit https://docs.splunk.com/Documentation/Splunk/8.2.1/DistSearch/HowconfrepoworksinSHC

The preferred method for distributing app configurables to a SHC is to put them on the SHC deployer and then push the bundle to the cluster.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

We need more information. How exactly are you saving the file ("using Python" is not enough)?  Which API or command are you using?  Where is the file being saved?

---
If this reply helps you, Karma would be appreciated.
0 Karma

alucarddjin
Path Finder

I didn't put to much detail in because I want to know what's best practice when dealing with a clustered search head.

Currently I'm using json.dump into the apps bin folder like this:

with open('/apps/appname/bin/fields.json','w') as file:
    json.dump(fields,file)

Again though I'm not set on this way, just what's the proper way to deal with writing on a clustered search head.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Thanks for clarifying.  SHCs do not replicate every file.  To see what is replicated, visit https://docs.splunk.com/Documentation/Splunk/8.2.1/DistSearch/HowconfrepoworksinSHC

The preferred method for distributing app configurables to a SHC is to put them on the SHC deployer and then push the bundle to the cluster.

---
If this reply helps you, Karma would be appreciated.

alucarddjin
Path Finder

Thanks for that. It points me in the right direction at least.

We do currently use the deplorer for this file but the issue comes up that people can't edit it on the search head without us having to put it into BitBucket then pushing to the deployed. I was hoping for a tool they could update in Splunk without devs being involved 😖

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...