Dashboards & Visualizations

How can I change Splunk Dashboard single value field color of the date format depending on the time delay

Prashant
Engager

Hi,

I have created a dashboard which shows the latest time of synching data between the two systems. Now I am interested to get the date color changed example: green(if sync time and current time difference is less than 1 hour) and red (if sync time and current time difference is more than 2 hour).

Is anything like that possible ? 

In the format visualization as far as I am seeing it I can change the color only for the single value and not for the datetime format.

Please anyone can assist. Below is the how my date format looks

 

Prashant_0-1651965297860.png

 

 

Labels (4)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

The xml I gave was for a dashboard, not a search query. For a search query use

| makeresults
          | eval count=random()%20
          | eval msg=case(count <= 5, "Unsuccessful", count > 15, "Successful", 1==1, "Middling")
          | eval range=case(count < 4, "severe", count < 8, "high", count < 12, "elevated", count < 16, "guarded", 1==1, "low")
          | table msg range

View solution in original post

0 Karma

Prashant
Engager

Perfect. Thank you so much sorted.

This is how its looking -

 

Prashant_0-1652032179567.png

 

example -

 

<dashboard script="table_row_highlighting.js" stylesheet="table_decorations.css">
<label>Table Row Color based on String Time Duration in HH:MM:SS</label>
<row>
<panel>
<single id="success">
<title>Success</title>
<search>
<query>index=kafka kafka_topic="*events*filter*sink" message.source="*velocloud*"
| eval LatestTime=strftime(_time,"%Y-%m-%d %H:%M:%S")
| eval TimeDiff=round((now()-_time)/60)
| eval msg = case(TimeDiff &gt;=59, "Delayed", TimeDiff &lt; 10, "Successful", 1=1, "Middling")
| eval range= case(TimeDiff &gt; 90, "severe", TimeDiff &gt; 59, "high", TimeDiff &gt; 30, "elevated", TimeDiff &lt; 10, "guarded", 1==1, "low")
| table LatestTime TimeDiff msg range</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
<option name="colorBy">value</option>
<option name="drilldown">none</option>
<option name="rangeColors">["red", "orange", "yellow", "blue","green"]</option>
<option name="refresh.display">progressbar</option>
<option name="trellis.enabled">0</option>
</single>
</panel>
</row>
</dashboard>

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try adding an extra field called range with "low" or "severe" (or "high", or "elevated", or "guarded") depending on the time difference and use the colorBy and rangeColors options. Here is a runanywhere example.

      <single id="success">
        <title>Success</title>
        <search>
          <query>| makeresults
          | eval count=random()%20
          | eval msg=case(count &lt;= 5, "Unsuccessful", count &gt; 15, "Successful", 1==1, "Middling")
          | eval range=case(count &lt; 4, "severe", count &lt; 8, "high", count &lt; 12, "elevated", count &lt; 16, "guarded", 1==1, "low")
          | table msg range</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="colorBy">value</option>
        <option name="drilldown">none</option>
        <option name="rangeColors">["red", "orange", "yellow", "blue","green"]</option>
        <option name="refresh.display">progressbar</option>
        <option name="trellis.enabled">0</option>
      </single>
    </panel>
0 Karma

Prashant
Engager

@ITWhisperer Thank you for the quick turnaround. But when I run the query that you provided its giving me these error. I am using Splunk Enterprise version 8.2.1

 

Prashant_0-1652022732400.png

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The xml I gave was for a dashboard, not a search query. For a search query use

| makeresults
          | eval count=random()%20
          | eval msg=case(count <= 5, "Unsuccessful", count > 15, "Successful", 1==1, "Middling")
          | eval range=case(count < 4, "severe", count < 8, "high", count < 12, "elevated", count < 16, "guarded", 1==1, "low")
          | table msg range
0 Karma
Get Updates on the Splunk Community!

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...

Reminder! Splunk Love Promo: $25 Visa Gift Card for Your Honest SOAR Review With ...

We recently launched our first Splunk Love Special, and it's gone phenomenally well, so we're doing it again, ...