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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...