Dashboards & Visualizations

How to get color added in the XMl?

jip31
Motivator

Hi

I use this colorpalette code in my xml
But the value of my threshold has To be in %
I do 10%,20% but it doesnt works
An idea please?

Code:

<format type="color" field="PercFreeSpace"> <colorPalette type="list">[#DC4E41,#EC9960,#53A051]</colorPalette> <scale type="threshold">10,20</scale> </format> 
0 Karma
1 Solution

niketn
Legend

@jip31, you can have table column value without percent, so that you can apply colorPalette. Then you can add Percent to the column using field format option in Simple XML. So following Simple XML code would get added to your existing settings:

        <format type="color" field="PercFreeSpace">
          <colorPalette type="list">[#DC4E41,#EC9960,#53A051]</colorPalette>
          <scale type="threshold">10,20</scale>
        </format>
        <format type="number" field="PercFreeSpace">
          <option name="unit">%</option>
          <option name="useThousandSeparators">false</option>
        </format>

Number format rules are listed in the Documentation: https://docs.splunk.com/Documentation/Splunk/latest/Viz/TableFormatsXML#Number_format_rules

alt text

Following is a run anywhere example based on your question:

<dashboard>
  <label>colorPalette range on Percent Field</label>
  <row>
    <panel>
      <title>Add Percent to column using Table Number Format</title>
      <table>
        <search>
          <query>| makeresults
| fields - _time
| eval data="range=low,PercFreeSpace=30%;range=medium,PercFreeSpace=18%;range=critical,PercFreeSpace=8%;"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| eval PercFreeSpace=replace(PercFreeSpace,"%","")
| table range, PercFreeSpace</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <format type="color" field="PercFreeSpace">
          <colorPalette type="list">[#DC4E41,#EC9960,#53A051]</colorPalette>
          <scale type="threshold">10,20</scale>
        </format>
        <format type="number" field="PercFreeSpace">
          <option name="unit">%</option>
          <option name="useThousandSeparators">false</option>
        </format>
      </table>
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@jip31, you can have table column value without percent, so that you can apply colorPalette. Then you can add Percent to the column using field format option in Simple XML. So following Simple XML code would get added to your existing settings:

        <format type="color" field="PercFreeSpace">
          <colorPalette type="list">[#DC4E41,#EC9960,#53A051]</colorPalette>
          <scale type="threshold">10,20</scale>
        </format>
        <format type="number" field="PercFreeSpace">
          <option name="unit">%</option>
          <option name="useThousandSeparators">false</option>
        </format>

Number format rules are listed in the Documentation: https://docs.splunk.com/Documentation/Splunk/latest/Viz/TableFormatsXML#Number_format_rules

alt text

Following is a run anywhere example based on your question:

<dashboard>
  <label>colorPalette range on Percent Field</label>
  <row>
    <panel>
      <title>Add Percent to column using Table Number Format</title>
      <table>
        <search>
          <query>| makeresults
| fields - _time
| eval data="range=low,PercFreeSpace=30%;range=medium,PercFreeSpace=18%;range=critical,PercFreeSpace=8%;"
| makemv data delim=";"
| mvexpand data
| rename data as _raw
| KV
| eval PercFreeSpace=replace(PercFreeSpace,"%","")
| table range, PercFreeSpace</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <format type="color" field="PercFreeSpace">
          <colorPalette type="list">[#DC4E41,#EC9960,#53A051]</colorPalette>
          <scale type="threshold">10,20</scale>
        </format>
        <format type="number" field="PercFreeSpace">
          <option name="unit">%</option>
          <option name="useThousandSeparators">false</option>
        </format>
      </table>
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

jip31
Motivator

Perfect! thanks

Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...