Dashboards & Visualizations

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

Prashant
Explorer

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

Prashant
Explorer

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>

Prashant
Explorer

@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
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...