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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...