Getting Data In

Is it possible to automatically update drop-down options with custom JavaScript based on an ingested CSV file?

test365498
Path Finder

I am wondering if the following is possible, and if so, how.

Currently I have a custom drop down-menu in a dashboard with a token for the options that are hard coded in XML.

Is it possible to create a custom JS script that, that based on a daily ingested CSV file, would add and/or remove options in this drop-down and add/or remove some charts?

Thank you!

tormodbp
Path Finder

I am sure you could use javascript to accomplish this, but I would like to propose an alternative approach using Splunks integrated features(why re-invent the wheel, right?).

For automatically updating dropdown options I would recommend using "Dynamic Options" integrated in Splunk's dropdown menus. Here you could specify a search to get your newest ingested CSV-files data. Lets say you import it around midnight every 24h, a "Last 24hour" search window would probably suffice.

Dynamic Options - Search string to populate the dropdown options

The dynamic options could then again be used to feed data to your charts(using tokens), thus effectively making you able to change your graphs on the fly - all without javascript.

Cheers,

test365498
Path Finder

Thank you for the information, very helpful! I have two follow up questions now. The ingested VSC file would always have to have the same name in order for the dynamic string to be able to search with that standard name in the search, correct? Furthermore, depending on these dynamic items in the drop down, could a graph in the dashboard be added/removed to demonstrate a metric for each of the drop down items (with or without JS)?

0 Karma

tormodbp
Path Finder

Yes, the file would have to have the same name. However you can directly update a lookup using the REST API. Here is an "Splunk>answers" that might help you along the way: https://answers.splunk.com/answers/374065/how-to-update-a-global-lookup-file-via-rest-api-fo.html

It is possible to hide/show a graph based on a token value. This can quite easily be done with Simple XML. Take a look at this "Splunk>answers" to get a working example:
Hide panels from dashboard

test365498
Path Finder

Wonderful! So for existing panels, they can be hidden if no value is available. But can they be created is the value in the drop down is new, or the new option would need to be added manually via XML? I am wondering how much manual upkeep this dash board would need, versus full automation.

0 Karma

tormodbp
Path Finder

It depends on what you put in to the term "created".

If you have a base query and the dynamic dropdown menu should change some parameters in the query, then yes. You can use tokens from the dropdown menu in the search, thus creating/updating a "specialised" result/chart for each selected entry in the dropdown menu. This would be like a "dynamic panel" based on the input from the dropdown menu.

If you expect a totally new base query per dropdown option you would need some way of specififying it, thus making things a little more complicated.

There might be a way of doing the latter without creating code to create new code, but that is out of my reach for the moment.

Good luck!

test365498
Path Finder

Thank you for your time!

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...