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.

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!

Guided Onboarding with Auto-schema Is Now Generally Available

  We are excited to announce the General Availability of Guided Onboarding with Auto-Schematization ...

ATTENTION: We’re Moving! (AGAIN!)

The Splunk Community Slack is undergoing a system migration to keep our workspace secure and ...

Deep Dive: Optimizing Telemetry Pipelines in Splunk Observability Cloud

In this session, we will peel back the layers of Splunk Observability Cloud’s cost-optimization features. ...