<?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: Change graph color based on value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214780#M62984</link>
    <description>&lt;P&gt;Create a new variable for each color of bar that you want: redCount, yellowCount, greenCount - for example&lt;/P&gt;

&lt;P&gt;Assign the count value to the appropriate variable&lt;/P&gt;

&lt;P&gt;Create a stacked column chart (or a stacked bar chart if you want it horizontally)&lt;/P&gt;

&lt;P&gt;Put the chart in a dashboard, so that you can set the color attributes for the bars&lt;/P&gt;

&lt;P&gt;Here is a simple XML example of the code snippet for a chart that should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;searchString&amp;gt;sourcetype=mysourcetype AND searchstuffforerrors | stats count by host 
     | eval redCount = if(count&amp;gt;20,count,0)
     | eval yellowCount = if(count&amp;lt;=20 AND count&amp;gt;15,count,0)
     | eval greenCount = if(count&amp;lt;=15, count, 0)
     | fields - count&amp;lt;/searchString&amp;gt;
   &amp;lt;title&amp;gt;Server Errors by Host - Last  24 hours&amp;lt;/title&amp;gt;
   &amp;lt;earliestTime&amp;gt;-24h@h&amp;lt;/earliestTime&amp;gt;
   &amp;lt;latestTime&amp;gt;@h&amp;lt;/latestTime&amp;gt;
   &amp;lt;option name="charting.chart"&amp;gt;column&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.chart.stackMode"&amp;gt;stacked&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.fieldColors"&amp;gt;{"redCount":0xFF0000,"yellowCount":0xFFFF00, "greenCount":0x73A550}&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.legend.placement"&amp;gt;none&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.legend.placement"&amp;gt;none&amp;lt;/option&amp;gt;     
   &amp;lt;option name="charting.axisLabelsX.majorLabelStyle.rotation"&amp;gt;90&amp;lt;/option&amp;gt;  
 &amp;lt;/chart&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that the last option sets the X-axis labels to print vertically on the column chart. If you prefer, you could set the charting.chart option to "bar" and then eliminate the option for charting.axisLabelsX.majorLabelStyle.rotation&lt;/P&gt;</description>
    <pubDate>Mon, 08 Aug 2016 12:02:52 GMT</pubDate>
    <dc:creator>hliakathali_spl</dc:creator>
    <dc:date>2016-08-08T12:02:52Z</dc:date>
    <item>
      <title>Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214777#M62981</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;This is re-putative question&amp;gt; I have verified couple articles to write query for updating colors based on value. I am able to set colors for a specified field, but it's not applying in the graph.  Below is the my search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=iis |eval page_time_taken=if(lower(cs_uri_stem)="/view/pages/default.aspx" AND sc_status!="401",time_taken,null()) |timechart avg(page_time_taken) as Average_Response|eval result= if(Average_Response&amp;lt;800, "Green",null())|eval result1=if(Average_Response&amp;gt;800  AND Average_Response&amp;lt;1000, "Yellow",null())|eval result2=if(Average_Response&amp;gt;1000, "Red",null())| rename result as "Average Response Time Below 800ms" result1 as "Average Response Time Below 1000ms" result2 as "Average Response Time Above 1000ms"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here, it is always Highlighting Average_Respond Color.&lt;/P&gt;

&lt;P&gt;Below is my dashboard XML.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Average_Response_Time_Test_Dashboard

&amp;lt;panel&amp;gt;
  &amp;lt;chart&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=main sourcetype=iis |eval page_time_taken=if(lower(cs_uri_stem)="/view/pages/default.aspx" AND sc_status!="401",time_taken,null()) |timechart avg(page_time_taken) as Average_Response|eval result= if(Average_Response &amp;lt;800, "Green",null())|eval result1=if(Average_Response&amp;gt;800  AND Average_Response&amp;lt;1000, "Yellow",null())|eval result2=if(Average_Response&amp;gt;1000, "Red",null())| rename result as "Average Response Time Below 800ms" result1 as "Average Response Time Below 1000ms" result2 as "Average Response Time Above 1000ms"&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
    &amp;lt;/search&amp;gt;
    &amp;lt;option name="charting.legend.placement"&amp;gt;right&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.legend.labelStyle.overflowMode"&amp;gt;ellipsisMiddle&amp;lt;/option&amp;gt;

    &amp;lt;option name="charting.layout.splitSeries.allowIndependentYRanges"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.layout.splitSeries"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.style"&amp;gt;shiny&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.stackMode"&amp;gt;default&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.sliceCollapsingThreshold"&amp;gt;0.01&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.showDataLabels"&amp;gt;&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.nullValueMode"&amp;gt;gaps&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.bubbleSizeBy"&amp;gt;area&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.bubbleMinimumSize"&amp;gt;10&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.bubbleMaximumSize"&amp;gt;50&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart"&amp;gt;column&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY2.scale"&amp;gt;inherit&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY2.enabled"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY.scale"&amp;gt;linear&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisX.scale"&amp;gt;linear&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisTitleY2.visibility"&amp;gt;visible&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisTitleY.visibility"&amp;gt;visible&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisTitleX.visibility"&amp;gt;visible&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisLabelsX.majorLabelStyle.rotation"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisLabelsX.majorLabelStyle.overflowMode"&amp;gt;ellipsisNone&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.fieldColors"&amp;gt;{"Average Response Time Above 1000ms":0xFF0000,"Average Response Time Below 1000ms":0xFFFF00,"Average Response Time Below 800ms":0x00FF00}&amp;lt;/option&amp;gt;
  &amp;lt;/chart&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help me on this.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 09:26:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214777#M62981</guid>
      <dc:creator>guruwells</dc:creator>
      <dc:date>2016-08-08T09:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214778#M62982</link>
      <description>&lt;P&gt;This doesnt work well on a timechart because the field values are _time...  This might work though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=iis 
| eval page_time_taken=if(lower(cs_uri_stem)="/view/pages/default.aspx" AND sc_status!="401",time_taken,null()) 
| stats avg(page_time_taken) as Average_Response by _time
| eval AR= if(Average_Response &amp;lt;800, "Green",if(Average_Response&amp;gt;800  AND Average_Response&amp;lt;1000, "Yellow",if(Average_Response&amp;gt;1000, "Red",null())))
| stats avg(page_time_taken) as Average_Response by AR,_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;CODE&gt;&amp;lt;option name="charting.fieldColors"&amp;gt;{"Red":0xFF0000,"Yellow":0xFFFF00,"Green":0x00FF00}&amp;lt;/option&amp;gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 10:49:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214778#M62982</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2016-08-08T10:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214779#M62983</link>
      <description>&lt;P&gt;Thanks for the mail. Your optimization query is good. But I wanted to display chart with colors if that condition matches. I hope without timechart command we can display data into graphical representation format?. I want to display data into dashboard with graphs.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 10:57:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214779#M62983</guid>
      <dc:creator>guruwells</dc:creator>
      <dc:date>2016-08-08T10:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214780#M62984</link>
      <description>&lt;P&gt;Create a new variable for each color of bar that you want: redCount, yellowCount, greenCount - for example&lt;/P&gt;

&lt;P&gt;Assign the count value to the appropriate variable&lt;/P&gt;

&lt;P&gt;Create a stacked column chart (or a stacked bar chart if you want it horizontally)&lt;/P&gt;

&lt;P&gt;Put the chart in a dashboard, so that you can set the color attributes for the bars&lt;/P&gt;

&lt;P&gt;Here is a simple XML example of the code snippet for a chart that should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;searchString&amp;gt;sourcetype=mysourcetype AND searchstuffforerrors | stats count by host 
     | eval redCount = if(count&amp;gt;20,count,0)
     | eval yellowCount = if(count&amp;lt;=20 AND count&amp;gt;15,count,0)
     | eval greenCount = if(count&amp;lt;=15, count, 0)
     | fields - count&amp;lt;/searchString&amp;gt;
   &amp;lt;title&amp;gt;Server Errors by Host - Last  24 hours&amp;lt;/title&amp;gt;
   &amp;lt;earliestTime&amp;gt;-24h@h&amp;lt;/earliestTime&amp;gt;
   &amp;lt;latestTime&amp;gt;@h&amp;lt;/latestTime&amp;gt;
   &amp;lt;option name="charting.chart"&amp;gt;column&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.chart.stackMode"&amp;gt;stacked&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.fieldColors"&amp;gt;{"redCount":0xFF0000,"yellowCount":0xFFFF00, "greenCount":0x73A550}&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.legend.placement"&amp;gt;none&amp;lt;/option&amp;gt;
   &amp;lt;option name="charting.legend.placement"&amp;gt;none&amp;lt;/option&amp;gt;     
   &amp;lt;option name="charting.axisLabelsX.majorLabelStyle.rotation"&amp;gt;90&amp;lt;/option&amp;gt;  
 &amp;lt;/chart&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that the last option sets the X-axis labels to print vertically on the column chart. If you prefer, you could set the charting.chart option to "bar" and then eliminate the option for charting.axisLabelsX.majorLabelStyle.rotation&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 12:02:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214780#M62984</guid>
      <dc:creator>hliakathali_spl</dc:creator>
      <dc:date>2016-08-08T12:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214781#M62985</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
This will print blank lines in the graph, how to avoid it...!?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 09:03:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214781#M62985</guid>
      <dc:creator>rohithmn3</dc:creator>
      <dc:date>2017-03-22T09:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214782#M62986</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;With this &lt;BR /&gt;
    eval Critical = if(PercentUsedSpace&amp;gt;70,PercentUsedSpace,0)&lt;BR /&gt;
a blank line gets added in the chart..! How to remove blank lines from it...!?&lt;BR /&gt;
Kindly help here..!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 09:05:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214782#M62986</guid>
      <dc:creator>rohithmn3</dc:creator>
      <dc:date>2017-03-22T09:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Change graph color based on value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214783#M62987</link>
      <description>&lt;P&gt;This can be used when we have to define range of values in count attribute. How can i make similar color customization on specific values of search result. For e.g., my search is calculating count of different severity i.e., High, Low, Medium, Severe. And i need to add color as per the following condition&lt;BR /&gt;
Severe-Red&lt;BR /&gt;
High- Orange&lt;BR /&gt;
Medium- Blue&lt;BR /&gt;
Low- Green&lt;/P&gt;

&lt;P&gt;The query i added in the dashboard and the respective XML is below:&lt;/P&gt;

&lt;P&gt;Incident Review Dashboard_new&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
  &amp;lt;chart&amp;gt;
    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;| datamodel Incident_Management Notable_Events search | stats count by severity | eval risk=case(severity="high","High_Risk",severity="low","Low_risk",severity="medium","medium_risk",severity="severe","severe_risk") | stats SUM(count) as count by risk |eval color_map=case(risk=High_Risk,"red",risk=low_risk,"yellow")&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;-24h@h&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="charting.axisLabelsX.majorLabelStyle.overflowMode"&amp;gt;ellipsisNone&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisLabelsX.majorLabelStyle.rotation"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisTitleX.visibility"&amp;gt;visible&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisTitleY.visibility"&amp;gt;visible&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisTitleY2.visibility"&amp;gt;visible&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisX.scale"&amp;gt;linear&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY.scale"&amp;gt;linear&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY2.enabled"&amp;gt;1&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY2.maximumNumber"&amp;gt;200&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY2.minimumNumber"&amp;gt;100&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.axisY2.scale"&amp;gt;inherit&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart"&amp;gt;bar&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.bubbleMaximumSize"&amp;gt;50&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.bubbleMinimumSize"&amp;gt;10&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.bubbleSizeBy"&amp;gt;area&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.nullValueMode"&amp;gt;gaps&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.overlayFields"&amp;gt;color_map&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.showDataLabels"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.sliceCollapsingThreshold"&amp;gt;0.01&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.stackMode"&amp;gt;stacked&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.chart.style"&amp;gt;shiny&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.layout.splitSeries"&amp;gt;1&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.layout.splitSeries.allowIndependentYRanges"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.legend.labelStyle.overflowMode"&amp;gt;ellipsisMiddle&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.legend.placement"&amp;gt;none&amp;lt;/option&amp;gt;
    &amp;lt;option name="trellis.enabled"&amp;gt;0&amp;lt;/option&amp;gt;
    &amp;lt;option name="trellis.scales.shared"&amp;gt;1&amp;lt;/option&amp;gt;
    &amp;lt;option name="trellis.size"&amp;gt;medium&amp;lt;/option&amp;gt;
    &amp;lt;option name="charting.fieldColors"&amp;gt;{"red":0xFF0000,"yellow":0xFFFF00}&amp;lt;/option&amp;gt;
  &amp;lt;/chart&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The color of the bar are still not changing. I feel i am missing something. Can somebody help ?&lt;/P&gt;</description>
      <pubDate>Sat, 30 Sep 2017 09:36:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Change-graph-color-based-on-value/m-p/214783#M62987</guid>
      <dc:creator>qbolbk59</dc:creator>
      <dc:date>2017-09-30T09:36:24Z</dc:date>
    </item>
  </channel>
</rss>

