Dashboards & Visualizations

SDK javascript: files error

LauraBre
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

psanford_splunk
Splunk Employee
Splunk Employee

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

psanford_splunk
Splunk Employee
Splunk Employee

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

LauraBre
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
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...