Splunk Dev

starting with javascript sdk

sbobrovs
Engager

Dear Experts,
I am need to demo very simple chart of Splunk as part of my web site.
As I am not Javascript expert I am getting some error.

If i need to connect from my web server do I need the :

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

the error that i am getting is

  1. POST http://localhost:58810/proxy/services/auth/login?output_mode=json 404 (Not Found) jquery.min.js:4
  2. List item

Can any once send me working sample ? for external web server.

Many Thanks,
Shachar

Tags (2)
0 Karma

Neeraj_Luthra
Splunk Employee
Splunk Employee

Hi Shachar,
By default, browsers don’t allow cross origin communication (http://en.wikipedia.org/wiki/Same_origin_policy). I suggest that you follow an approach similar to what is in the UI examples that are shipped with the Splunk SDK for JavaScript, i.e. go through a proxy -

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

In addition to that, since your webserver is different from where Splunk is running, you will also need to tell your web server to handle these proxy requests and delegate them to the right address, i.e. Splunk’s management port.

For Apache, adding these 2 lines to httpd.conf does the trick.


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

You will have to do something similar to your web server’s conf. Make sure to put the right host and port depending on your splunk configuration.

Hope this helps.

Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...