Dashboards & Visualizations
Highlighted

SDK javascript: files error

Communicator

hello,

I want to use SDK javascript. I installed splunk in local. Now I tried to connect to my local splunk with the sdk, it's work very well. I have a list of my search's results... Now I want to have chart in my web page so I try to use SDK javascript. I test this html page:

<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">
    var service = new splunkjs.Service({username: "admin", password: "admin"});
    service.login(function(err, success) {
        if (err) {
             console.log("erreur");
            throw err;
        }
        console.log("Login was successful: " + success);
        service.jobs().fetch(function(err, jobs) {
            var list = jobs.list();
            for(var i = 0; i < list.length; i++) {
                console.log("Job " + i + ": " + list[i].sid);
            } 
        });
    });
</script>

<html>
<head>OK</head>
</html>

I have a problem because in my project the splunk.js and several javascripts files indicates error but I just copy and paste folder client and jquery.js from the sdk javascript that I download. My html page indicate just OK when I launch it in my browser and no error appear in my log console of my browser but if the connection works, I have to have the message "Login was successful" else "erreur" but I have nothing. Where does it come from???

Thx by advance,

Laura

0 Karma
Highlighted

Re: SDK javascript: files error

Communicator

Hi Laura - Which chart are you trying to work with? I would recommend starting with one of the chart components that we provide in the SDK. You can see them in the examples directory. Take a look at this page on dev.splunk.com: http://dev.splunk.com/view/SP-CAAAEDC

It shows how to run the examples that we ship. This is a nice simple web app that shows you the code that is required to display a chart.

Generally, you will need to run a search, which I don't see in your code example. You then take the results from that search and then you have to draw the chart and pass in the search results. The examples app that we ship shows code for that for Google charts, Rickshaw and the Splunk timeline and charting views. Hope that helps.

0 Karma
Highlighted

Re: SDK javascript: files error

Communicator

Hello,

Thanks very much for your answer. I see that there are this app but I don't able to start node.js because when I try to launch it, it say "did you forget to run 'npm install?' but I download node.js which include the module npm so I don't able to say why it doesn't work.

I want to see pie chart of column chart in my web page.

Thx by advance if you know where is the problem.

Laura

0 Karma
Highlighted

Re: SDK javascript: files error

Communicator

It will include the npm module but then you should have to run 'npm install' from the command line. There are instructions here: http://dev.splunk.com/view/SP-CAAAEFN

0 Karma
Speak Up for Splunk Careers!

We want to better understand the impact Splunk experience and expertise has has on individuals' careers, and help highlight the growing demand for Splunk skills.