Dashboards & Visualizations

splunkJavascript: problem methods

LauraBre
Communicator

Hi,

I try to use the SDK javsacript in my dynamic web project J2EE so I create a proxy servlet and a page .html so the authentification in Splunk works because I don't have the error message alert of this page:

<html>
  <head>
    <meta charset="utf-8">
    <title>How to start a Splunk session</title>
    <script type="text/javascript" src="scripts/jquery.min.js"></script>
    <script type="text/javascript" src="scripts/client/splunk.js"></script>

    <script type="text/javascript" charset="utf-8">
    function displayApps() {
        var http = new splunkjs.ProxyHttp("servlet/proxy");
        // Create a Service instance and log in 
        var service = new splunkjs.Service(http, {
            username: "admin",
            password: "admin",
            scheme: "https",
            host: "localhost",
            port: "8089"
        });



        // Print installed apps to the console to verify login
         service.apps().fetch(function(err, apps) {
            if (err) {
                alert("Error listing apps");
                return;
            }

         console.log("success connection");

         service.serverInfo(function(err, info) {
         console.log("Splunk Version: ", info.properties().version);
     });
            var myapps = "";
            var appsList = apps.list();

            for(var i = 0; i < appsList.length; i++) {
                myapps += "App " + i + ": " + appsList[i].name + "<br/>"
            } 

            document.getElementById("applist").innerHTML=myapps;
        });

    }
    </script> 
</head>
<body>
    <button type="button" onclick="displayApps()">Log in and list apps</button>
    <p id="applist"></p>
</body>
</html>

I see the message success connection and I can show in my console of firebug all methods can use but I don't able to have version information, list of apps, ...
Where can my problem come from?

Thx by advance,

Laura

Tags (2)
0 Karma

hoyacom
Engager

I've met same problem so what did you do for this problem. can I ask about this problem ?

0 Karma

Neeraj_Luthra
Splunk Employee
Splunk Employee

Hi Laura - It might be better for us to connect offline. Once you are able to get the Splunk communication and your web-app up and running, I can post the final response on splunk-base. You can simply shoot me an email at nluthra@splunk.com.

0 Karma
Get Updates on the Splunk Community!

Devesh Logendran, Splunk, and the Singapore Cyber Conquest

At this year’s Splunk University, I had the privilege of chatting with Devesh Logendran, one of the winners in ...

There's No Place Like Chrome and the Splunk Platform

WATCH NOW!Malware. Risky Extensions. Data Exfiltration. End-users are increasingly reliant on browsers to ...

Customer Experience | Join the Customer Advisory Board!

Are you ready to take your Splunk journey to the next level? &#x1f680; We invite you to join our elite squad ...