Dashboards & Visualizations

How to use single value in HTML on a dashboard ?

john_loch
Explorer

Hi there,

I have a simple question for dashboard/view gurus..

I have a dashboard with a panel containing just HTML. I want to embed a single value resulting from a hidden search in the HTML so it appears as part of the text.

I understand singlevalues, but I'm not sure how to obtain a singlevalue as plaintext (ie not as a button etc).

Is there a quick easy way to do this ?

Thanks 🙂

Tags (1)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

There is not. SingleValues only work inside of an entire view XML module and include all the HTML that is generated.

The way to get what you want would be to have a simple API level call that you could make from within your own web page/web application. This kind of thing does exist in the Splunk REST API. However, it's rather poorly documented and poorly supported.

The SDK is in Python, so really you could in principle call it from within a Splunk HTML page. As it turns out, the "HTML" isn't HTML, but rather CherryPy/mako template, which means that you can use Python libraries within it. Conveniently, since it runs inside of the SplunkWeb server, the libraries etc are already loaded and available. Inconveniently, there is a distinct lack of examples or explicit support for using this, though in my opinion it would be more flexible than the Splunk View XML.

View solution in original post

0 Karma

cpuppet
Path Finder

try sideview util, it has a detail example and description of how to use html instead of single value module

araitz
Splunk Employee
Splunk Employee

I'm not sure that Gk's is the right answer. Don't hit me pradafan1!!!

I use SingleValue quite a bit to inject things like "Splunk sees 6000 hosts" or "473 cats have died since you made your that girl on the bus cry" into my dashboards, and hardly ever use them as buttons. The trick is that you might have to use some CSS to make it "pretty". See my FireEye app on Splunkbase for some examples.

You can also use NullModules with application.js to make the NullModule do, well, just about anything you want. If you aren't too confident with your hacking skills but need something done fast and right, I know a guy named Nick Mealy that makes for a great hired gun. You might say he has some subject mater expertise.

gkanapathy
Splunk Employee
Splunk Employee

There is not. SingleValues only work inside of an entire view XML module and include all the HTML that is generated.

The way to get what you want would be to have a simple API level call that you could make from within your own web page/web application. This kind of thing does exist in the Splunk REST API. However, it's rather poorly documented and poorly supported.

The SDK is in Python, so really you could in principle call it from within a Splunk HTML page. As it turns out, the "HTML" isn't HTML, but rather CherryPy/mako template, which means that you can use Python libraries within it. Conveniently, since it runs inside of the SplunkWeb server, the libraries etc are already loaded and available. Inconveniently, there is a distinct lack of examples or explicit support for using this, though in my opinion it would be more flexible than the Splunk View XML.

0 Karma

sideview
SplunkTrust
SplunkTrust

This is certainly possible, and there's no need to think about writing your own webapp and trying to integrate against the python SDK. that's silly. Since he's only asking to embed the dynamic value within simple text, the trick is that all that text goes into the SingleValue params, and none into the . Also, this sort of thing is a lot easier in Sideview Utils. Sideview Utils contains 20-some pages of its own docs, among which you'll find "Using the HTML module to replace SingleValue". However you'll also have to say goodbye to the simple xml.

0 Karma

john_loch
Explorer

Thanks gkanapathy,

I'm surprised that something as simple as acquiring a single plain text result for use in a Dashboard is that challenging.

Thanks for responding so promptly 🙂

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

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 ...