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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...