Splunk Search

Form Creation, Wildcard use

jsb22
Path Finder

Essentailly I'm trying to create a form that uses a wildcard by default so users can just hit search on page load and get all values of the field, then the user can input specific values in the field so they can limit what they're seeing. When I specify "< default>*< /default>" it errors out with "Error in 'search' command: Unable to parse the search: Comparator '=' is missing a term on the right hand side". THe fieldset and searchTemplate stream is as follows:

< fieldset>
< input type="text" token="Administrator" />
< default>*< /default>
< /fieldset>

< searchTemplate>(index=windows_7 OR index=windows_2008_R2) source=wineventlog:security EventCode=4720 src_user=$Administrator$ | table _time, src_user, host, dest_nt_domain, signature, user, Display_Name< /searchTemplate>

Tags (2)
0 Karma
1 Solution

MHibbin
Influencer

I may be missing something but I don't know why you have to used \ in your search string..

You can use HTML characters (link here) or you can encase your search in CDATA brackets. However I do not see any of these special characters in your XML.

I have put a working form example in the comment below (for some reason I couldn't get it to appear in answer correctly.. even with "Code Sample" or backticks).

Alos notice I have encased $SRC$ in *'s, this allows for wildcarding on text entered.

Regards,

MHibbin

View solution in original post

MHibbin
Influencer

I may be missing something but I don't know why you have to used \ in your search string..

You can use HTML characters (link here) or you can encase your search in CDATA brackets. However I do not see any of these special characters in your XML.

I have put a working form example in the comment below (for some reason I couldn't get it to appear in answer correctly.. even with "Code Sample" or backticks).

Alos notice I have encased $SRC$ in *'s, this allows for wildcarding on text entered.

Regards,

MHibbin

MHibbin
Influencer

Great News!!

0 Karma

jsb22
Path Finder

Turns out it was the escape character, I tested that before, and it didn't work, tested again to try to digest what the CDATA statement does and it worked, must have fat-fingered it somewhere. So my origional code was correct except for the escape character you recommended. Thanks again!

0 Karma

MHibbin
Influencer

Also to add in for others... the CDATA syntax would be


<![CDATA[search_string_here]]>

0 Karma

MHibbin
Influencer

Ha! Ok... I just edited answer... was having some issues getting Splunkbase to allow my XML... kept creating a form input in the answer!!! 😄

0 Karma

MHibbin
Influencer
(index=main OR index=test) SRC=`*$SRC$*` | stats count by SRC DST -30d -0d
*
test 20
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...