Splunk Search

Choose one result in Splunk table Query

PraveenaR
Explorer

Hello All, 

1) I would like to add radio button / any way to select - one of the results of my below REST query search,

QUERY :    |rest /services/data/ui/views | table id label updated "eai:userName" "eai:data" "eai:appName"

PraveenaR_0-1641449559138.png

2) This Query search is saved as a dashboard (auto-refresh) and I have added few text boxes (User Name, Commit Branch, User Token) as show in the attached image. These text boxes will be manually filled by user.  

 

Use Case: I need to choose any one row via radio button (or any other technical way) and then click on the SUBMIT button to send the selected row data and text box (manually entered by user) data to my custom python script. 

What is the way to achieve this use case in Splunk, Any help on this is appreciated. 

Thanks!

0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

(Because your search is likely to result in many rows, dropdown is a better choice than radio button.  I will use dropdown in example.)  To set  up a selector for id, for example, put the following in the "Search String" box under "Dynamic Options":

|rest /services/data/ui/views
| stats count by id

then put the string id in both "Field for Label" and "Field for Value".  If you inspect Simple  XML source, you'll see something like

    <input type="dropdown" token="id_tok" searchWhenChanged="true">
      <label>id</label>
      <fieldForLabel>id</fieldForLabel>
      <fieldForValue>id</fieldForValue>
      <search>
        <query>|rest /services/data/ui/views
| stats count by id</query>
      </search>
      <choice value="%">Any</choice>
    </input>

 In the above, I also added a static option "Any" with value of "%".

Similarly, you can add a dynamic dropdown for label,

    <input type="dropdown" token="label_tok" searchWhenChanged="true">
      <label>label</label>
      <fieldForLabel>label</fieldForLabel>
      <fieldForValue>label</fieldForValue>
      <search>
        <query>|rest /services/data/ui/views
| stats count by label</query>
      </search>
      <choice value="%">Any</choice>
      <default>%</default>
    </input>

And so on.

Then, in the panel search box, enter

| rest /services/data/ui/views
| where id LIKE "$id_tok$" AND label LIKE "$label_tok$"
| table id label updated "eai:userName" "eai:data" "eai:appName"

Hope this helps.

View solution in original post

yuanliu
SplunkTrust
SplunkTrust

(Because your search is likely to result in many rows, dropdown is a better choice than radio button.  I will use dropdown in example.)  To set  up a selector for id, for example, put the following in the "Search String" box under "Dynamic Options":

|rest /services/data/ui/views
| stats count by id

then put the string id in both "Field for Label" and "Field for Value".  If you inspect Simple  XML source, you'll see something like

    <input type="dropdown" token="id_tok" searchWhenChanged="true">
      <label>id</label>
      <fieldForLabel>id</fieldForLabel>
      <fieldForValue>id</fieldForValue>
      <search>
        <query>|rest /services/data/ui/views
| stats count by id</query>
      </search>
      <choice value="%">Any</choice>
    </input>

 In the above, I also added a static option "Any" with value of "%".

Similarly, you can add a dynamic dropdown for label,

    <input type="dropdown" token="label_tok" searchWhenChanged="true">
      <label>label</label>
      <fieldForLabel>label</fieldForLabel>
      <fieldForValue>label</fieldForValue>
      <search>
        <query>|rest /services/data/ui/views
| stats count by label</query>
      </search>
      <choice value="%">Any</choice>
      <default>%</default>
    </input>

And so on.

Then, in the panel search box, enter

| rest /services/data/ui/views
| where id LIKE "$id_tok$" AND label LIKE "$label_tok$"
| table id label updated "eai:userName" "eai:data" "eai:appName"

Hope this helps.

Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...