All Apps and Add-ons

Automatically redirect when search completes

kmattern
Builder

I have a situation where the user will make a selection on a form using the DBX connector. I wanted to use Django but Django doesn't like the search, all the double quotes in the SQL Query confuse it. So I want to let the user make the selections from pulldowns and then automatically redirect after the search completes. The search will output to a lookup table. Then redirect to the Django page which will search the lookup table and display a chart. I'm thinking that this should be something Sideview Utils can handle.

sideview
SplunkTrust
SplunkTrust

To prevent a Redirector from doing the redirector until after a search completes, you might think to use a Sideview Gate module, in combination with a ValueSetter and it's "conditional" logic, as applied to $results.isDone$. At least, that was my first thought and if you've used Gate before it feels like Gate should be able to do it.

However I just looked into this and neither Gate module nor ValueSetter module realizes at runtime that it should rethink things at the moment that the job completes, so the relevant keys remain blank. =(

2) Fortunately ResultsValueSetter gives you a decent workaround for the time being. ResultsValueSetter, in the course of doing what it does, halts the push, waits for the job to complete, and then it resumes the push. As such this makes it perfect here (even though we dont actually need it's handy ability to grab a field value and turn it into a $foo$ token)

So you can use ResultsValueSetter to make a pretty simple "redirect when search X is complete" configuration. (In fact in a way it's simpler than a Gate+ValueSetter solution would have been)

<module name="Search" layoutPanel="panel_row1_col1" autoRun="True">
  <param name="search"><![CDATA[
    index=* OR index=_* | head 100000 | stats count
  ]]></param>

  <module name="Button">

    <module name="ResultsValueSetter">
      <param name="fields">foo</param>

      <module name="Redirector">
        <param name="url">http://google.com</param>
        <param name="popup">True</param>

      </module>
    </module>
  </module>
</module>

NOTE: the fields param in RVS is "foo" because we dont actually need it, so it doesn't matter if it exists. In this particular case you can put anything there so I put "foo".

However some general caveats.

a) There are still some weird bits down in the module framework about when the modules think the page has finished loaded and when they believe it to still be loading. Sideview has patched and improved a lot of this, but long story short - some modules, in some configurations, still believe the page is "loading" when in fact it's all done.

b) Redirector module, for various reasons, doesn't actually trigger the redirect if at the moment when it receives a push, it thinks the page is still loading.

c) combining #1 and #2, the overall behavior is buggy in some complex cases. The typical symptom is that a redirect doesn't happen when it should, but if you click the same thing again, it does. I mention this in case you see it in your own (more complex) configs, and you can of course report it to me if you like.

The example config above doesn't actually suffer from this problem so for now you can ignore this longwinded caveat.

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 ...