Splunk Search

Has anyone been able to create a form search that updates a lookup table?

the_wolverine
Champion

I want to add a form field to a dashboard that would allow a user to input some text. Somehow this text, perhaps using outputlookup, would append to a lookup table. The only issue I see is that this text doesn't yet exist in our data until the user enters it in the form. A bit backwards, yes.

The usecase is for updating a list of domains. We'd like to add a domain to a blacklist or a whitelist for searching.

the_wolverine
Champion

Thank you Brian! Is there an easy solution to provide the user a way to submit?

I added a SubmitButton to your example, but I'm getting an intentions error using my method:

<module name="HiddenSearch" autoRun="True">
  <param name="search">| inputlookup domains.csv | append [stats count | eval domain="$domain_addition$" | fields - _time | fields domain] | dedup domain |  outputlookup domains.csv</param>
      <module name="SubmitButton">
       <param name="label">click to submit</param>
      <module name="ViewRedirector" layoutPanel="viewHeader">
        <param name="viewTarget">flashtimeline</param>

ERROR:

PARSER: Applying intentions failed 'unicode' object has no attribute 'get'
0 Karma

bwooden
Splunk Employee
Splunk Employee

I added a submit button to my original answer while updating the method a bit.

0 Karma

bwooden
Splunk Employee
Splunk Employee

Below is one way you could add the value of an input field to a lookup file...
sandbox

[edited to correct syntax]

<module name="ExtendedFieldSearch" layoutPanel="panel_row1_col1">
    <param name="field">Domain</param>
    <param name="default">foo.com</param>
    <param name="intention">
        <param name="name">stringreplace</param>
        <param name="arg">
            <param name="domain_addition">
                <param name="prefix"> </param>
                <param name="fillOnEmpty">True</param>
                <param name="suffix"> </param>
            </param>
        </param>
    </param>
    <param name="replacementMap">
        <param name="arg">
            <param name="domain_addition">
                <param name="value" />
            </param>
        </param>
    </param>
    <module name="SubmitButton">
        <param name="label">click to submit</param>
        <module name="HiddenSearch">
            <param name="search">| inputlookup domains.csv | append [stats count | eval domain=trim("$domain_addition$") | fields - _time | fields domain] | dedup domain |  outputlookup domains.csv</param>
            <module name="SimpleResultsTable" />
        </module>
    </module>
</module>

bwooden
Splunk Employee
Splunk Employee

I like it and edited my response to match. Thanks!

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Using stats count is better than search * | head 1 if you just need a dummy row. It works even if there is no data in the index (for your role or whatever), and doesn't actually even need to touch the index at all, and produces only a known field count.

Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...