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!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

Stay Connected: Your Guide to October Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...