Getting Data In

How to get the Multiselect input to create a search without " when selecting multiple values

uthornander_spl
Splunk Employee
Splunk Employee

I'm trying to create a training dashboard based on Multiselect and the HTTP status code.
If I create the Multiselect through the GUI and only select a single value - all works fine.
But when I select more than 1 value, the search fails.
The reason is that the search is created as ---- status="200 OR 503" ----- (I added the OR separator)
If I remove the "" it all works fine but nowhere in the GUI do you have a choice to omit the ""

UT
Tags (2)
0 Karma
1 Solution

cmerriman
Super Champion

try using " OR status=" as the delimiter

View solution in original post

0 Karma

cmerriman
Super Champion

try using " OR status=" as the delimiter

0 Karma

uthornander_spl
Splunk Employee
Splunk Employee

Tried a few approaches but your suggestion gives me
status="200 OR status=400"

Then I tried adding a leading " in the separator, but then I get
status="400\" OR status=200"

Trying exactly what you wrote gives me
status="200\" OR status=\"400"

Somehow Search seems to think I don't speak SPL good enough 😞
BTW - running on 7.0

UT
0 Karma

cmerriman
Super Champion

can you send a snippet of the simpleXML for this input? i'm not sure why the \\ would be added.

0 Karma

uthornander_spl
Splunk Employee
Splunk Employee

I have to correct myself. This is a 6.6.2 instance for a Rookie session.
Here's what the XML looks like:

Blockquote

<input type="multiselect" token="status_token" searchWhenChanged="true">
  <label>Status</label>
  <choice value="*">All</choice>
  <fieldForLabel>status</fieldForLabel>
  <fieldForValue>status</fieldForValue>
  <search>
    <query>sourcetype=access_combined* product_id=$product_token|s$| stats count by status</query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
  </search>
  <default>*</default>
  <delimiter> OR </delimiter>
</input>
UT
0 Karma

cmerriman
Super Champion

doing this should work and you shouldn't need the |s in status_token in your search because the statuses are all numerical fields, so there really isn't a need to enclose them in quotes.

<input type="multiselect" token="status_token" searchWhenChanged="true">
      <label>Status</label>
      <choice value="*">All</choice>
      <fieldForLabel>status</fieldForLabel>
      <fieldForValue>status</fieldForValue>
      <search>
        <query>sourcetype=access_combined* product_id=$product_token|s$| stats count by status</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <default>*</default>
      <delimiter> OR status=</delimiter>
    </input>
0 Karma

uthornander_spl
Splunk Employee
Splunk Employee

Thanks
The key was the numerical fields so now the working solution looks like

sourcetype=access_combined* product_id=$product_token|s$ status=$status_token$| iplocation clientip | geostats count by status

Didn't see any point in using a different syntax for a numerical field vs a text field - but then again 🙂

UT
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...