<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Complex Color Rule in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459704#M30166</link>
    <description>&lt;P&gt;Hello all and thanks&lt;/P&gt;

&lt;P&gt;@ renjith : i have just added this in my xml&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;format type="color" field="diff"&amp;gt;
&amp;lt;colorPalette type="list"&amp;gt;[#DC4E41,#EC9960,#53A051]&amp;lt;/colorPalette&amp;gt;
&amp;lt;scale type="threshold"&amp;gt;10,20&amp;lt;/scale&amp;gt;
&amp;lt;/format&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is it ok because the field is not colored? &lt;BR /&gt;
The entire code is &lt;BR /&gt;
    &lt;QUERY&gt;index="perfmon" sourcetype="perfmon:logicaldisk" instance=c:  counter="Free Megabytes" OR counter="% Free Space"| search host=$tok_filterhost$&lt;BR /&gt;
    | eval perc_free = if(counter="% Free Space",Value,null)&lt;BR /&gt;
    | eval mb_free = if(counter="Free Megabytes",Value,null)&lt;BR /&gt;
    | stats latest(mb_free) as mb_free latest(perc_free) as perc_free by _time, host, instance&lt;BR /&gt;
     | eval total_space = mb_free / (perc_free) * 100  | eval DiskSize = round(mb_free/1024,2)." MB / ".round(total_space/1024,2)." MB"|eval time = strftime(_time, "%d-%m-%y %H:%M") |table time host instance DiskSize  |sort  -time&lt;/QUERY&gt;&lt;BR /&gt;
              &lt;EARLIEST&gt;$tok_time.earliest$&lt;/EARLIEST&gt;&lt;BR /&gt;
              &lt;LATEST&gt;$tok_time.latest$&lt;/LATEST&gt;&lt;BR /&gt;
            &lt;BR /&gt;
            10&lt;BR /&gt;
            row&lt;BR /&gt;
            progressbar&lt;BR /&gt;
            &lt;FORMAT type="color" field="diff"&gt;&lt;BR /&gt;
               &lt;COLORPALETTE type="list"&gt;[#DC4E41,#EC9960,#53A051]&lt;/COLORPALETTE&gt;&lt;BR /&gt;
               &lt;SCALE type="threshold"&gt;10,20&lt;/SCALE&gt;&lt;BR /&gt;
             &lt;/FORMAT&gt;&lt;/P&gt;

&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:39:06 GMT</pubDate>
    <dc:creator>jip31</dc:creator>
    <dc:date>2020-09-29T20:39:06Z</dc:date>
    <item>
      <title>Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459700#M30162</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I use this code in order to display the difference between the free space disk and the total space disk&lt;BR /&gt;
I need to create a color alert in the field&lt;BR /&gt;
when the difference between space disk and total disk is less than 20 GB, i want the field to be colored in orange and when the difference is less thant 10 GB i want the field colored in red&lt;BR /&gt;
I dont need the display the difference value but just to color my field&lt;BR /&gt;
I doesnt see any possibility to add a calcul in the color field rules&lt;BR /&gt;
How to do please???&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="perfmon" sourcetype="perfmon:logicaldisk" instance=c:  counter="Free Megabytes" OR counter="% Free Space"| search host=*
| eval perc_free = if(counter="% Free Space",Value,null)
| eval mb_free = if(counter="Free Megabytes",Value,null)
| stats latest(mb_free) as mb_free latest(perc_free) as perc_free by _time, host, instance
 | eval total_space = mb_free / (perc_free) * 100  | eval DiskSize = round(mb_free/1000,2)." MB / ".round(total_space/1000,2)." MB"|eval time = strftime(_time, "%d-%m-%y %H:%M") |table time host instance DiskSize  |sort  -time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 10:58:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459700#M30162</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2018-07-25T10:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459701#M30163</link>
      <description>&lt;P&gt;@jip31,&lt;/P&gt;

&lt;P&gt;There are minor adjustments you need to get the actual result. The disk space from perfmon is on MB and by dividing by 1000 you are getting the space in GB and also it should be by 1024 instead of 1000 for accurate results. Also calculate the difference between the total and used &lt;CODE&gt;eval diff=round((total_space-mb_free)/1024,2)&lt;/CODE&gt;&lt;BR /&gt;
So the search will be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="perfmon" sourcetype="perfmon:logicaldisk" instance=c:  counter="Free Megabytes" OR counter="% Free Space"| search host=*
 | eval perc_free = if(counter="% Free Space",Value,null)
 | eval mb_free = if(counter="Free Megabytes",Value,null)
 | stats latest(mb_free) as mb_free latest(perc_free) as perc_free by _time, host, instance
  | eval total_space = mb_free / (perc_free) * 100  | eval diff=round((total_space-mb_free)/1024,2)|eval DiskSize = round(mb_free/1024,2)." GB / ".round(total_space/1024,2)." GB"|eval time = strftime(_time, "%d-%m-%y %H:%M") |table time host instance DiskSize diff  |sort  -time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you have this in the table, you could change the color on basis of 'diff' column by just editing the visualization &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.1.2/Viz/TableFormats"&gt;https://docs.splunk.com/Documentation/Splunk/7.1.2/Viz/TableFormats&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Sample dashboard - you might need to adjust the sourcetype and instance&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;perf&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index="perfmon" sourcetype="Perfmon:disk" counter="Free Megabytes" OR counter="% Free Space"
| eval perc_free = if(counter="% Free Space",Value,null)
| eval mb_free = if(counter="Free Megabytes",Value,null)
| stats latest(mb_free) as mb_free latest(perc_free) as perc_free by _time, host, instance
| eval total_space = mb_free / (perc_free) * 100  | eval diff=round((total_space-mb_free)/1024,2) | eval DiskSize = round(mb_free/1024,2)." GB / ".round(total_space/1024,2)." GB"|eval time = strftime(_time, "%d-%m-%y %H:%M") 
| table time host instance DiskSize,diff  |sort  -time&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;true&amp;lt;/option&amp;gt;
        &amp;lt;format type="color" field="diff"&amp;gt;
          &amp;lt;colorPalette type="list"&amp;gt;[#DC4E41,#EC9960,#53A051]&amp;lt;/colorPalette&amp;gt;
          &amp;lt;scale type="threshold"&amp;gt;10,20&amp;lt;/scale&amp;gt;
        &amp;lt;/format&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 14:50:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459701#M30163</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-07-25T14:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459702#M30164</link>
      <description>&lt;P&gt;There are a whole bunch of different ways, none of them difficult, based on what you might be trying to do.  I believe this first one may be what you are looking for, but there are some additional links at the end.  &lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/230164/how-to-get-a-table-cell-color-to-change-depending.html"&gt;https://answers.splunk.com/answers/230164/how-to-get-a-table-cell-color-to-change-depending.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Also, our awesome Splunk Trust member @niketnilay posted a great fully-described example here - &lt;A href="https://answers.splunk.com/answers/583047/can-i-color-a-cell-based-on-condition.html"&gt;https://answers.splunk.com/answers/583047/can-i-color-a-cell-based-on-condition.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you work your way through that, you should be able to get exactly what you need.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Here's some other references:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/613766/how-can-i-change-the-color-of-the-single-value-vis.html"&gt;https://answers.splunk.com/answers/613766/how-can-i-change-the-color-of-the-single-value-vis.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/58335/change-chart-bar-color-based-on-data-value.html"&gt;https://answers.splunk.com/answers/58335/change-chart-bar-color-based-on-data-value.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/469656/how-to-change-the-background-color-of-the-panels-i.html"&gt;https://answers.splunk.com/answers/469656/how-to-change-the-background-color-of-the-panels-i.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/200861/how-to-change-bar-colors-in-a-bar-chart-based-on-v.html"&gt;https://answers.splunk.com/answers/200861/how-to-change-bar-colors-in-a-bar-chart-based-on-v.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 14:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459702#M30164</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-07-25T14:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459703#M30165</link>
      <description>&lt;P&gt;Thanks Dal &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I think the question here by @jip31 is to color by difference but do not show difference in the table, rather show the free space alone (not even the total space). This is slightly tricky but possible thanks to the following post by @kamlesh_vaghela: &lt;A href="https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html#answer-661940"&gt;https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html#answer-661940&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The approach of answer would be &lt;BR /&gt;
1) To have table with with free space and total space both in the same field in the table (possibly with delimiter like comma or semi-colon between them).&lt;/P&gt;

&lt;P&gt;2) Use Simple XML JS Extension to define Custom Table Cell Renderer for combined field. Use javaScript to Split the two values in Cell and get the difference.&lt;/P&gt;

&lt;P&gt;3) Set the class for color based on range for difference.&lt;/P&gt;

&lt;P&gt;4) Finally while rendering the table cell value keep only the Free space and discard the total space value.&lt;/P&gt;

&lt;P&gt;Please try out and confirm whether you need a  mock run anywhere example similar to your query. &lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 19:05:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459703#M30165</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-07-25T19:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459704#M30166</link>
      <description>&lt;P&gt;Hello all and thanks&lt;/P&gt;

&lt;P&gt;@ renjith : i have just added this in my xml&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;format type="color" field="diff"&amp;gt;
&amp;lt;colorPalette type="list"&amp;gt;[#DC4E41,#EC9960,#53A051]&amp;lt;/colorPalette&amp;gt;
&amp;lt;scale type="threshold"&amp;gt;10,20&amp;lt;/scale&amp;gt;
&amp;lt;/format&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is it ok because the field is not colored? &lt;BR /&gt;
The entire code is &lt;BR /&gt;
    &lt;QUERY&gt;index="perfmon" sourcetype="perfmon:logicaldisk" instance=c:  counter="Free Megabytes" OR counter="% Free Space"| search host=$tok_filterhost$&lt;BR /&gt;
    | eval perc_free = if(counter="% Free Space",Value,null)&lt;BR /&gt;
    | eval mb_free = if(counter="Free Megabytes",Value,null)&lt;BR /&gt;
    | stats latest(mb_free) as mb_free latest(perc_free) as perc_free by _time, host, instance&lt;BR /&gt;
     | eval total_space = mb_free / (perc_free) * 100  | eval DiskSize = round(mb_free/1024,2)." MB / ".round(total_space/1024,2)." MB"|eval time = strftime(_time, "%d-%m-%y %H:%M") |table time host instance DiskSize  |sort  -time&lt;/QUERY&gt;&lt;BR /&gt;
              &lt;EARLIEST&gt;$tok_time.earliest$&lt;/EARLIEST&gt;&lt;BR /&gt;
              &lt;LATEST&gt;$tok_time.latest$&lt;/LATEST&gt;&lt;BR /&gt;
            &lt;BR /&gt;
            10&lt;BR /&gt;
            row&lt;BR /&gt;
            progressbar&lt;BR /&gt;
            &lt;FORMAT type="color" field="diff"&gt;&lt;BR /&gt;
               &lt;COLORPALETTE type="list"&gt;[#DC4E41,#EC9960,#53A051]&lt;/COLORPALETTE&gt;&lt;BR /&gt;
               &lt;SCALE type="threshold"&gt;10,20&lt;/SCALE&gt;&lt;BR /&gt;
             &lt;/FORMAT&gt;&lt;/P&gt;

&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459704#M30166</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-29T20:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459705#M30167</link>
      <description>&lt;P&gt;@jip31,&lt;BR /&gt;
This is missing in your search &lt;CODE&gt;| eval diff=round((total_space-mb_free)/1024,2)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Try below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="perfmon" sourcetype="perfmon:logicaldisk" instance=c: counter="Free Megabytes" OR counter="% Free Space"
| search host=$tok_filterhost$ | eval perc_free = if(counter="% Free Space",Value,null) | eval mb_free = if(counter="Free Megabytes",Value,null) 
| stats latest(mb_free) as mb_free latest(perc_free) as perc_free by _time, host, instance | eval total_space = mb_free / (perc_free) * 100 
| eval diff=round((total_space-mb_free)/1024,2) 
| eval DiskSize = round(mb_free/1024,2)." MB / ".round(total_space/1024,2)." MB"|eval time = strftime(_time, "%d-%m-%y %H:%M") 
| table time host instance DiskSize diff|sort -time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jul 2018 07:13:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459705#M30167</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-07-26T07:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459706#M30168</link>
      <description>&lt;P&gt;i have succedeed renjith but i would like to have the cell colored in the disksize field and not in the diff field....&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 07:58:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459706#M30168</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2018-07-26T07:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Color Rule</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459707#M30169</link>
      <description>&lt;P&gt;As mentioned above by @niketnilay, you might need js , &lt;A href="https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html#answer-661940"&gt;https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html#answer-661940&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 13:16:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Complex-Color-Rule/m-p/459707#M30169</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-07-26T13:16:20Z</dc:date>
    </item>
  </channel>
</rss>

