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!

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Customers Increasingly Choose Splunk for Observability

For the second year in a row, Splunk was recognized as a Leader in the 2024 Gartner® Magic Quadrant™ for ...