Splunk Dev

Call to custom/eai endpoint from setup view

breid1313
Path Finder

Hello all - 

I'm creating a setup view (migrating from setup.xml) for an app and would like to continue to leverage the custom eai python handler that is already in place.

Can anyone point me towards an example of this? I may be using web.conf incorrectly as I can access the handler via port 8089 but when I attempt to call the endpoint from the setup view via the splunkjs sdk it generates a 404 error.

Once I resolve this issue I believe I should be able to pass all the parameters necessary into data: {TODO} in order to use the eai handler the same way we were when using setup.xml

 

app.js

 

 

 

    callScript(){
      $.ajax({
            type: "POST",
            url: "/servicesNS/-/<app_name>/configureMyApp/handleConfig",
            data: {TODO},
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
                console.log("success returned");
                console.log(data);
            },
            error: function(xhr){
     console.log("Error ", xhr);
         }
      });
    }

 

 

 

 

restmap.conf

 

 

[admin:configureMyApp]
match                 = /configureMyApp
members               = handleConfig        

[admin_external:handleConfig]
handlertype           = python
python.version        = python3
handlerfile           = handler.py
handleractions        = list, edit
handlerpersistentmode = false

 

 

 

web.conf

 

 

[expose:configureMyApp]
methods = GET, POST
pattern = configureMyApp

[expose:handleConfig]
pattern = configureMyApp/*
methods = GET, POST

 

 

Labels (4)
0 Karma

breid1313
Path Finder

My goals could also be accomplished with a [script:] stanza as well. Since we are using a setup view now, all the configuration is done with the splunkjs SDK before the python script is called, so I don't necessarily need an eai endpoint. All I'm looking to do is test a connection to a third-party app using a custom endpoint.

Same question applies here though. I've messed with the examples but get 404's through the js sdk using both a [script:] and [admin:]/[admin_external:] endpoint.

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...