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!

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...

Uncovering Multi-Account Fraud with Splunk Banking Analytics

Last month, I met with a Senior Fraud Analyst at a nationally recognized bank to discuss their recent success ...

Secure Your Future: A Deep Dive into the Compliance and Security Enhancements for the ...

What has been announced?  In the blog, “Preparing your Splunk Environment for OpensSSL3,”we announced the ...