Dashboards & Visualizations

Hidden Dropdown that dynamically selects index based on the selection of another dropdown

moumoutaru
Engager

Hello,

I am running into an issue with using multiple dropdowns What I am trying to achieve is dynamic index selection via a hidden splunk dropdown filter that get's autopopulated with the first result value from the datasource search on the hidden dropdown. The hidden filter's data source query for populating the dropdown makes uses the token from the first dropdown.

What seems to be working:
- Hidden Dropdown successfully lists the correct index based on the selection from the first dropdown.

What isn't working:
- The result from the hidden index datasource search isn't selected despite it being the only result returned and default selected values is set to first value.

Any thoughts or recommendations for how to handle this problem?

Labels (2)
Tags (1)
0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Hi @moumoutaru 

I did something similar last week for someone else who wanted to derive multiple tokens based on a single dropdown, I ended up create a table search off the side of the visibile dashboard using the token from the dropdown, which then allows them to use the $searchName.result.<field>$ in there other searches. 

I think this same approach could work for what you are trying to achieve, as the problem with a search on a hidden dropdown which selects the first result, is that if you change the value of the visible dropdown, whilst the search does re-run for the hidden one, it doesnt change the selected value!

Check out this link for an example (https://community.splunk.com/t5/Dashboards-Visualizations/Dropdown-filter-in-Splunk-dashboard-studio...) or find the sample dashboard below to have a play around with to see what I mean:

{
    "title": "Answers - testing",
    "description": "",
    "inputs": {
        "input_mwKjgBTB": {
            "options": {
                "items": [
                    {
                        "label": "useast01",
                        "value": "useast01"
                    },
                    {
                        "label": "uswest01",
                        "value": "uswest01"
                    },
                    {
                        "label": "usqaf01",
                        "value": "usqaf01"
                    }
                ],
                "selectFirstSearchResult": true,
                "token": "cluster"
            },
            "title": "Cluster",
            "type": "input.dropdown"
        }
    },
    "defaults": {
        "dataSources": {
            "ds.search": {
                "options": {
                    "queryParameters": {
                        "earliest": "$global_time.earliest$",
                        "latest": "$global_time.latest$"
                    }
                }
            }
        }
    },
    "visualizations": {
        "viz_2uQp06o5": {
            "dataSources": {
                "primary": "ds_c8AfQapt"
            },
            "type": "splunk.table"
        },
        "viz_JQgp3c9c": {
            "containerOptions": {},
            "dataSources": {
                "primary": "ds_eGOCKAoM_ds_qBGlESX2"
            },
            "eventHandlers": [
                {
                    "options": {
                        "tokens": [
                            {
                                "key": "name",
                                "token": "method"
                            }
                        ]
                    },
                    "type": "drilldown.setToken"
                }
            ],
            "options": {
                "majorValue": "> sparklineValues | lastPoint()",
                "trendValue": "> sparklineValues | delta(-2)"
            },
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Cluster",
            "type": "splunk.singlevalue"
        },
        "viz_bxuHwYLl": {
            "containerOptions": {},
            "dataSources": {
                "primary": "ds_FKvGrvZ4_ds_qBGlESX2"
            },
            "eventHandlers": [
                {
                    "options": {
                        "tokens": [
                            {
                                "key": "name",
                                "token": "method"
                            }
                        ]
                    },
                    "type": "drilldown.setToken"
                }
            ],
            "options": {
                "majorValue": "> sparklineValues | lastPoint()",
                "trendValue": "> sparklineValues | delta(-2)"
            },
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Space",
            "type": "splunk.singlevalue"
        },
        "viz_column_chart": {
            "containerOptions": {},
            "dataSources": {
                "primary": "ds_qBGlESX2"
            },
            "eventHandlers": [
                {
                    "options": {
                        "tokens": [
                            {
                                "key": "name",
                                "token": "method"
                            }
                        ]
                    },
                    "type": "drilldown.setToken"
                }
            ],
            "options": {
                "majorValue": "> sparklineValues | lastPoint()",
                "trendValue": "> sparklineValues | delta(-2)"
            },
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Region",
            "type": "splunk.singlevalue"
        }
    },
    "dataSources": {
        "ds_FKvGrvZ4_ds_qBGlESX2": {
            "name": "get_space",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval space=\"$myvars:result.space$\""
            },
            "type": "ds.search"
        },
        "ds_c8AfQapt": {
            "name": "myvars",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval cluster=\"$cluster$\"\n| eval space=CASE(cluster==\"usqaf01\", \"abs-qff\", cluster==\"uswest01\",\"abs-qpp1\",cluster==\"useast01\",\"abs-qpp1\")\n| eval region=CASE(cluster==\"usqaf01\", \"QAF\", cluster==\"uswest01\",\"QAWEST\",cluster==\"useast01\",\"QAEAST\")",
                "queryParameters": {
                    "earliest": "-24h@h",
                    "latest": "now"
                }
            },
            "type": "ds.search"
        },
        "ds_eGOCKAoM_ds_qBGlESX2": {
            "name": "get_cluster",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval cluster=\"$myvars:result.cluster$\""
            },
            "type": "ds.search"
        },
        "ds_qBGlESX2": {
            "name": "Search_1",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval region=\"$myvars:result.region$\""
            },
            "type": "ds.search"
        }
    },
    "layout": {
        "globalInputs": [
            "input_mwKjgBTB"
        ],
        "layoutDefinitions": {
            "layout_1": {
                "options": {
                    "display": "auto",
                    "height": 960,
                    "width": 1440
                },
                "structure": [
                    {
                        "item": "viz_column_chart",
                        "position": {
                            "h": 250,
                            "w": 350,
                            "x": 370,
                            "y": 0
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_2uQp06o5",
                        "position": {
                            "h": 100,
                            "w": 580,
                            "x": 1480,
                            "y": 70
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_JQgp3c9c",
                        "position": {
                            "h": 250,
                            "w": 350,
                            "x": 0,
                            "y": 0
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_bxuHwYLl",
                        "position": {
                            "h": 250,
                            "w": 350,
                            "x": 740,
                            "y": 0
                        },
                        "type": "block"
                    }
                ],
                "type": "absolute"
            }
        },
        "tabs": {
            "items": [
                {
                    "label": "New tab",
                    "layoutId": "layout_1"
                }
            ]
        }
    }
}

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

View solution in original post

moumoutaru
Engager

I'll give that a try Will. Thanks for the suggestion!

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @moumoutaru 

I did something similar last week for someone else who wanted to derive multiple tokens based on a single dropdown, I ended up create a table search off the side of the visibile dashboard using the token from the dropdown, which then allows them to use the $searchName.result.<field>$ in there other searches. 

I think this same approach could work for what you are trying to achieve, as the problem with a search on a hidden dropdown which selects the first result, is that if you change the value of the visible dropdown, whilst the search does re-run for the hidden one, it doesnt change the selected value!

Check out this link for an example (https://community.splunk.com/t5/Dashboards-Visualizations/Dropdown-filter-in-Splunk-dashboard-studio...) or find the sample dashboard below to have a play around with to see what I mean:

{
    "title": "Answers - testing",
    "description": "",
    "inputs": {
        "input_mwKjgBTB": {
            "options": {
                "items": [
                    {
                        "label": "useast01",
                        "value": "useast01"
                    },
                    {
                        "label": "uswest01",
                        "value": "uswest01"
                    },
                    {
                        "label": "usqaf01",
                        "value": "usqaf01"
                    }
                ],
                "selectFirstSearchResult": true,
                "token": "cluster"
            },
            "title": "Cluster",
            "type": "input.dropdown"
        }
    },
    "defaults": {
        "dataSources": {
            "ds.search": {
                "options": {
                    "queryParameters": {
                        "earliest": "$global_time.earliest$",
                        "latest": "$global_time.latest$"
                    }
                }
            }
        }
    },
    "visualizations": {
        "viz_2uQp06o5": {
            "dataSources": {
                "primary": "ds_c8AfQapt"
            },
            "type": "splunk.table"
        },
        "viz_JQgp3c9c": {
            "containerOptions": {},
            "dataSources": {
                "primary": "ds_eGOCKAoM_ds_qBGlESX2"
            },
            "eventHandlers": [
                {
                    "options": {
                        "tokens": [
                            {
                                "key": "name",
                                "token": "method"
                            }
                        ]
                    },
                    "type": "drilldown.setToken"
                }
            ],
            "options": {
                "majorValue": "> sparklineValues | lastPoint()",
                "trendValue": "> sparklineValues | delta(-2)"
            },
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Cluster",
            "type": "splunk.singlevalue"
        },
        "viz_bxuHwYLl": {
            "containerOptions": {},
            "dataSources": {
                "primary": "ds_FKvGrvZ4_ds_qBGlESX2"
            },
            "eventHandlers": [
                {
                    "options": {
                        "tokens": [
                            {
                                "key": "name",
                                "token": "method"
                            }
                        ]
                    },
                    "type": "drilldown.setToken"
                }
            ],
            "options": {
                "majorValue": "> sparklineValues | lastPoint()",
                "trendValue": "> sparklineValues | delta(-2)"
            },
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Space",
            "type": "splunk.singlevalue"
        },
        "viz_column_chart": {
            "containerOptions": {},
            "dataSources": {
                "primary": "ds_qBGlESX2"
            },
            "eventHandlers": [
                {
                    "options": {
                        "tokens": [
                            {
                                "key": "name",
                                "token": "method"
                            }
                        ]
                    },
                    "type": "drilldown.setToken"
                }
            ],
            "options": {
                "majorValue": "> sparklineValues | lastPoint()",
                "trendValue": "> sparklineValues | delta(-2)"
            },
            "showLastUpdated": false,
            "showProgressBar": false,
            "title": "Region",
            "type": "splunk.singlevalue"
        }
    },
    "dataSources": {
        "ds_FKvGrvZ4_ds_qBGlESX2": {
            "name": "get_space",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval space=\"$myvars:result.space$\""
            },
            "type": "ds.search"
        },
        "ds_c8AfQapt": {
            "name": "myvars",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval cluster=\"$cluster$\"\n| eval space=CASE(cluster==\"usqaf01\", \"abs-qff\", cluster==\"uswest01\",\"abs-qpp1\",cluster==\"useast01\",\"abs-qpp1\")\n| eval region=CASE(cluster==\"usqaf01\", \"QAF\", cluster==\"uswest01\",\"QAWEST\",cluster==\"useast01\",\"QAEAST\")",
                "queryParameters": {
                    "earliest": "-24h@h",
                    "latest": "now"
                }
            },
            "type": "ds.search"
        },
        "ds_eGOCKAoM_ds_qBGlESX2": {
            "name": "get_cluster",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval cluster=\"$myvars:result.cluster$\""
            },
            "type": "ds.search"
        },
        "ds_qBGlESX2": {
            "name": "Search_1",
            "options": {
                "enableSmartSources": true,
                "query": "| makeresults\n| eval region=\"$myvars:result.region$\""
            },
            "type": "ds.search"
        }
    },
    "layout": {
        "globalInputs": [
            "input_mwKjgBTB"
        ],
        "layoutDefinitions": {
            "layout_1": {
                "options": {
                    "display": "auto",
                    "height": 960,
                    "width": 1440
                },
                "structure": [
                    {
                        "item": "viz_column_chart",
                        "position": {
                            "h": 250,
                            "w": 350,
                            "x": 370,
                            "y": 0
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_2uQp06o5",
                        "position": {
                            "h": 100,
                            "w": 580,
                            "x": 1480,
                            "y": 70
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_JQgp3c9c",
                        "position": {
                            "h": 250,
                            "w": 350,
                            "x": 0,
                            "y": 0
                        },
                        "type": "block"
                    },
                    {
                        "item": "viz_bxuHwYLl",
                        "position": {
                            "h": 250,
                            "w": 350,
                            "x": 740,
                            "y": 0
                        },
                        "type": "block"
                    }
                ],
                "type": "absolute"
            }
        },
        "tabs": {
            "items": [
                {
                    "label": "New tab",
                    "layoutId": "layout_1"
                }
            ]
        }
    }
}

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...