Splunk Dev

Parsing URL Paramaters in Web Framework

jamesvz84
Communicator

I have a simplexml dashboard that I want to drilldown into a django/web framework dashboard and pass along some parameters in the URL. How can the web framework dashboard receive/parse these parameters for use in a search?

0 Karma

peter_krammer
Communicator

Today I had the same use case to implement and I posted my solution here:
http://answers.splunk.com/answers/114196/how-to-pass-tokens-in-url-using-the-new-web-framework.html#...

0 Karma

jamesvz84
Communicator

I was able to achieve this like so:

URL: ....myserver:8000/dj/en-us/myapp/mydashboard/?app=myapp

Inside javascript section (within the require(xxx) block):

function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
    results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

var application= getParameterByName('app');
tokens.set("application", application);

Then in block managers section:

{% searchmanager
    id="dropdown_results"
    app="myapp"
    search='search application="$application$"'|token_safe
    preview=True
    autostart=True
    earliest_time="$earlyval$"|token_safe
    latest_time="$lateval$"|token_safe
%}
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...