Dashboards & Visualizations

add custom name in chart viz for empty space

kpavan
Path Finder

Hi All,

I got requirement where we need to display custom name like "maintenance" during planned activity when there will be no data and while displaying in chart currently its empty space, but needed to display as maintenance as custom word. I tried with fillnull it doesn't show in chart but in table it does. 

index=myindex source=mysource status=*
| timechart count as total, count(eval(status=="PASS")) as Success,count(eval(status=="Fail")) as Failure
| eval PF=round((Failure/total)*100), "Success%"=round((100-PF))

Please let me know any suggestions to achieve this.

 

Thanks!
Pavan

Labels (1)
Tags (1)
0 Karma

niketn
Legend

@kpavan you have following 2 options:

Option 1 : Splunk built in Chart Event Annotationhttps://docs.splunk.com/Documentation/Splunk/latest/Viz/ChartEventAnnotations

Screen Shot 2020-06-22 at 11.26.41 PM.png

Option 2 : Region Chart Custom Visualization by @chrisyounger : https://splunkbase.splunk.com/app/4911/

Screen Shot 2020-06-22 at 11.26.27 PM.png

Following is a run anywhere example for both examples above. The example assumes maintenance window every Sunday from 8:00 PM to midnight.

PS: For the second option to work you would need to get Region Chart custom visualization from Splunkbase.

 

<dashboard theme="light">
  <label>Maintenance Window</label>
  <row>
    <panel>
      <title>Option 1: Maintenance Window using Splunk Chart Event Annotation</title>
      <chart>
        <search type="annotation">
          <query>| makeresults
| addinfo
| eval _time=split($tokEarliestTime|s$."|".$tokLatestTime|s$,"|")
| stats count by _time
| timechart count span=1h
| fields - count
| eval isMaintenanceWindow=if(strftime(_time,"%a")=="Sun" AND tonumber(strftime(_time,"%H"))&gt;20,"Maintenance Window Sunday 8:00 PM - 11:59 PM","Regular")
| search isMaintenanceWindow="Maintenance Window Sunday 8:00 PM - 11:59 PM"
| eval annotation_label=isMaintenanceWindow</query>
        </search>
        <search>
          <query>index=_internal sourcetype=splunkd log_level=WARN
| timechart count as ERRORS span=1h
| fillnull value=0 ERRORS</query>
          <earliest>-15d@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
          <progress>
            <eval token="tokEarliestTime">strptime($job.earliestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
            <eval token="tokLatestTime">strptime($job.latestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
          </progress>
        </search>
        <!-- Secondary search that drives the annotations -->
        <option name="charting.axisTitleX.visibility">collapsed</option>
        <option name="charting.axisTitleY.visibility">collapsed</option>
        <option name="charting.chart">line</option>
        <option name="charting.legend.placement">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
    </panel>
  </row>
  <row>
    <panel id="panel_chart_error_trend">
      <title>Option 2: Maintenance Window using Region Chart Custom Visualization</title>
      <viz type="region_chart_viz.region_chart_viz">
        <search>
          <progress>
            <eval token="tokEarliestTime">strptime($job.earliestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
            <eval token="tokLatestTime">strptime($job.latestTime$,"%Y-%m-%dT%H:%M:%S.%3N%z")</eval>
          </progress>
          <query>index=_internal sourcetype=splunkd log_level=WARN
| timechart count as ERRORS span=1h
| fillnull value=0 ERRORS
| eval regions=if(strftime(_time,"%a")=="Sun" AND tonumber(strftime(_time,"%H"))&gt;20,"Maintenance Window Sunday 8:00 PM - 11:59 PM=red","")</query>
          <earliest>-15d@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="drilldown">all</option>
        <option name="refresh.display">progressbar</option>
      </viz>
    </panel>
  </row>
</dashboard>

 

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
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 ...