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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...