All Apps and Add-ons

How can I create a setup page for a custom app?

Leo
Splunk Employee
Splunk Employee

Working by examples of Windows and Unix apps I'm trying to build a setup page for my app. It has a scripted input for which I would like to configure some parameters using the setup screen like in the aforementioned apps.

I figured that setup.xml file that defines contents of the setup screen would require an EAI endpoint. So I tried to create one inside my app. For this I've put this stanza in restmap.conf:

[admin_external:myappconf]
handlertype=python
handlerfile=myappconfhandler.py
handleractions=list, edit

and also created myappconfhandler.py inside bin directory:

import splunk.admin as admin

class MyAppConfig(admin.MConfigHandler):
    def setup(self):
        if self.requestedAction == admin.ACTION_EDIT:
            for arg in ['enabled', 'pollInterval']:
                self.supportedArgs.addOptArg(arg)

    def handleList(self, confInfo):
        confInfo['1'].append('asd', 'zxc')
        confInfo['1'].append('bbb', 'aaa')
        confInfo['2'].append('asd', 'zxc')
        confInfo['2'].append('bbb', 'aaa')

    def handleEdit(self, confInfo):
        name = self.callerArgs.id
        args = self.callerArgs
        # to be completed

# initialize the handler, and add the actions it supports.    
admin.init(MyAppConfig, admin.CONTEXT_NONE)

But going to https://localhost:8089/services/admin/myappconf returned me 404..

Are the EAI endpoints restricted from being defined inside custom apps? If so, is it still possible to create a setup page somehow?

Tags (3)
1 Solution

amrit
Splunk Employee
Splunk Employee

that config is valid - are you sure your app is enabled?

View solution in original post

amrit
Splunk Employee
Splunk Employee

that config is valid - are you sure your app is enabled?

Leo
Splunk Employee
Splunk Employee

Yes, the app was disabled. I changed in app.conf: state = enabled and now I can access my endpoint. Also one needs to make sure splunk is restarted after config changes are made.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...