Dashboards & Visualizations

Javascript SDK internal server error

guilhem
Contributor

Hi

So I have splunk 4.2 installed on a remote server, I have downloaded the javascript SDK on my local machine, along with node v0.8.9.

I copied the xml2json from my local machine to var/apps on the server.

When I try to run the examples using node sdkdo examples, the example show in my local web browser.

I have set up a proxy in my local apache web server (I use MAMP) like this:

httpd.conf

SSLProxyEngine On
ProxyPass /proxy/ https://My remote server

I have enabled some stuff in this file:


Header set Access-Control-Allow-Origin: *
Header set Access-Control-Allow-Methods: GET,POST,PUT,DELETE
Header set Access-Control-Allow-Headers: X-ProxyDestination,Authorization

To allow AJAX cross domain request.

When I hit the Run button of the example, I get this:

POST http://localhost:6969/proxy/services/auth/login?output_mode=json 500 (Internal Server Error)

When I try to edit the index.html example and replace the line

var http = new splunkjs.ProxyHttp("/proxy");

with

var http = new splunkjs.ProxyHttp("http://localhost/proxy");

I get this error

(MAMP active):
OPTIONS http://localhost/proxy/services/auth/login?output_mode=json 200 (OK) jquery.min.js:4
POST http://localhost/proxy/services/auth/login?output_mode=json 404 (Not Found)
(MAMP inactive)
OPTIONS http://localhost/proxy/services/auth/login?output_mode=json Resource failed to load

I don't know what's going on. I am not a server guy, nor a js developper, but I try to do my best to make it works.

Thanks!

Neeraj_Luthra
Splunk Employee
Splunk Employee

Leave the proxy to be "/proxy" as that matches your conf changes in MAMP's httpd.conf. The location you copied xml2json to is incorrect. You need to place it inside the etc/apps folder on the server.

Also, if you are using MAMP to serve the examples, you don't really need node at all.

0 Karma

Neeraj_Luthra
Splunk Employee
Splunk Employee

I assume you are referring to the cross-domain paragraph.

The MAMP httpd.conf should have these lines,

SSLProxyEngine On
ProxyPass /proxy/ https://localhost:8089/

And after you restart MAMP, it should proxy the requests for Splunk correctly. Did you have the port defined in httpd.conf? Try the lines above and see if it works (assuming your Splunk is running locally on default ports, i.e. 8000 for UI and 8089 for management)

0 Karma

guilhem
Contributor

Sorry didn't check it but I have the xml2json in the right place (/etc/apps)

I really don't understand how to set up everything here (can't understand this page: http://dev.splunk.com/view/SP-CAAAEFM, last paragraph)

0 Karma
Get Updates on the Splunk Community!

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 ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...