splunk test1

curl -k -u admin:changeme  https://localhost:8089/services/auth/login -d username=admin -d password=changeme

http://dev.splunk.com/view/SP-CAAAEWS

http://docs.splunk.com/Documentation/Splunk/6.6.2/RESTREF/RESTaccess#auth.2Flogin

 

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>Search Controls: Tokens</title>

扫描二维码关注公众号,回复: 218592 查看本文章

 

    <link rel="stylesheet" type="text/css" href="static/splunkjs/css/bootstrap.css" />

    <style>

        .main-area {

            padding: 30px;

        }

    </style>

</head>

 

<body>

    <div>

        <div class="main-area">

            <p>This example shows how to set up SearchBar and SearchControls views using Django tags, and sync them with a SearchManager using tokens.</p>

            <p><b>Note:</b> The Timeline view can't be synced using tokens. Use events instead.</p>

 

            <div id="mysearchbar1"></div>

            <div id="mysearchcontrols1"></div>

            <div id="mytable1"></div>

        </div>

    </div>

 

    <script src="static/splunkjs/config.js"></script>

 

    <script>

        // Configure SplunkJS Stack

        splunkjs.config({

   scheme: 'https',

   host: '192.168.1.6',

   port: 8089,

   authenticate: {username: 'admin', password: 'abcd'},

});

        /* splunkjs.config({

            scheme: "https",

            host: "localhost",

            port: 8089,

            authenticate: function(done) { 

                require([

                    "jquery",

                    "jquery.cookie"

                ], function($) {

                    // Retrieve the session key and username from cookies

                    var splunkSessionKey = $.cookie("splunk_sessionkey");

                    var splunkCurrentUser = $.cookie("splunk_username");

 

                    // Log in using the session key and username

                    if (splunkSessionKey) {

                        done(null, {sessionKey: splunkSessionKey, username: splunkCurrentUser}); 

                    }

                    // If there is no session key, redirect to the login form

                    else {

                        window.location.replace("login_form.html");

                    }

                });

            }

        }); */

        

        // Configure the web site's base URL

        require.config({

            baseUrl: "static/"

        });

 

        // Set up the Web Framework components

        var deps = [

            "splunkjs/ready!",

            "splunkjs/mvc/searchmanager",

            "splunkjs/mvc/searchbarview",

            "splunkjs/mvc/searchcontrolsview",

            "splunkjs/mvc/tableview"

        ];

        require(deps, function(mvc) {

            // Load individual components

            var SearchManager = require("splunkjs/mvc/searchmanager");

            var SearchbarView = require("splunkjs/mvc/searchbarview");

            var SearchControlsView = require("splunkjs/mvc/searchcontrolsview");

            var TableView = require("splunkjs/mvc/tableview");

 

            // Create the search manager and views

            var mysearch = new SearchManager({

                id: "search1",

                search: mvc.tokenSafe("$searchquery$"),

                earliest_time: mvc.tokenSafe("$earlyval$"),

                latest_time: mvc.tokenSafe("$lateval$"),

                app: "search",

                preview: true,

                required_field_list: "*",

                status_buckets: 300

            });

 

            var mysearchbar = new SearchbarView({

                id: "searchbar1",

                managerid: "search1",

                value: mvc.tokenSafe("$searchquery$"),

                timerange_earliest_time: mvc.tokenSafe("$earlyval$"),

                timerange_latest_time: mvc.tokenSafe("$lateval$"),

                default: "index=_internal | head 100",

                el: $("#mysearchbar1")

            }).render();

 

            var mysearchcontrols = new SearchControlsView({

                id: "searchcontrols1",

                managerid: "search1",

                el: $("#mysearchcontrols1")

            }).render();

 

            var mytable = new TableView({

                id: "table1",

                managerid: "search1",

                el: $("#mytable1")

            }).render();

        });

    </script>

</body>

</html>

猜你喜欢

转载自qgl.iteye.com/blog/2389688