Dashboards & Visualizations

Single Value Button going to red/amber/green based on dynamic threshold value

adityapavan18
Contributor

Hi

I have a scenario where i have to put a single value button showing a avg response time that would go red/amber/green on going on/off a threshold.

This is easy and can be done using range if there is a constant threshold value.

Now in my scenario, the threshold value is not constant and needs to be changed with time, and the single value button will go red/amber/green based on the threshhold value at that point of time.

How do i specify threshold based on time?

Can this be done in splunk dashboards.Please suggest

santosh_hb
Explorer

Hi, I am a newbie in Splunk. Currently, I am also working on the same issue as above i.e. the threshold value is dynamic and keeps changing with time. I need to display red, green and amber based on the threshold value. i.e. if the latency is 20% of threshold then red icon should be displayed, if the latency is 50% of threshold then green icon should be displayed and if the latency is 120% of threshold then amber icon should be displayed.
As, I am new to .css and .js, I am unable to understand the above code. Can anyone please share the entire code (i.e. xml code, .css and .js code). It will be of much help for me.
Currently, I have created a sample .csv file that contains the following fields:
Ex: data_hour (1/1/13 8:00 AM), Latency (secs): 1.25, Threshold: 1
Thanks in advance.

0 Karma

linu1988
Champion

Please use the application.css and .js file to acheive the goal. Have a column where it shows normal/warning/critical using eval statement.

In my case i am using .SimpleResultsTable module where i will do exchange for image for a value.

App.css:
.SimpleResultsTable td.Normal {
background-image: url(images/normal.gif/png); [depends on browser]
background-repeat:no-repeat;
background-position:5px 3px;
}

.js file:

onResultsRendered: function() {
this.forEachCellInColumn("State", function(tdElement) {
if (tdElement.text()=="Started") {
tdElement.text("").addClass("Normal");
} else {
tdElement.text("").addClass("Warning");
}
});
}
Add these codes, which will work on a dashboard.

adityapavan18
Contributor

Thnx a lot. Look-up way should do the trick thnx

0 Karma

linu1988
Champion

It depends what is your requirements are like! If your threshold values are varying with time, create a lookup / using eval statement find the exact threshold value for that Hour. I will give an example

eval threshold=case(date_hour =9 threshold, "3", date_hour =11, "5")|eval State=case(value <= threshold, "Normal", value >= threshold*1.2, "warning", value >= threshold*1.5, "Critical")|Table State

then as i mentioned above replace the codes and place a image with relevant color to appserver/static/images folder. it will do the job what you want

0 Karma

adityapavan18
Contributor

My doubt is that i dont have a constant threshold value.The threshold value changes with time? how do you factor that into that?? example at 9:00 AM the threshold value is 3 it will go to amber at 120% of 3 and red at 150%3 ..where the i need the threshold to be changed to 5 at 11:00 AM now the amber state with will more than 120% of 5 and so ..

0 Karma

linu1988
Champion

if you do a simple view on a dashboard, you will be able to use "simpleresultstable" module for displaying your eval field value. So i am not sure which i should explain? The .js file will replace the value with image on the go.

0 Karma

adityapavan18
Contributor

Thnks. But could you elaborate/explain the solution u gave.

0 Karma
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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...