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!

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