Example search tested in Splunk 7.3.1 using makeresults , eval , and append commands to generate example data (three events, each with two fields: Day and Errors 😞
| makeresults
| eval Day="Daybeforethat", Errors=20
| append
[| makeresults
| eval Day="Yesterday", Errors=40 ]
| append
[| makeresults
| eval Day="Today", Errors=80 ]
| eval Good = if(Errors <= 30,'Errors',null), Bad = if((Errors > 30) AND (Errors <= 50),'Errors',null), Ugly = if((Errors > 50),'Errors',null)
| table Day, Good, Bad, Ugly
Given existing search-based results with the same structure—three rows (one for each day), each with two fields ( Day and Errors )—the search effectively consists of just the last two commands ( eval Good ... and table ).
Significant charting options ( chart.stackMode and fieldColors 😞
<option name="charting.chart.stackMode">stacked</option>
<option name="charting.fieldColors">{"Good": 0x66cc66, "Bad": 0xcccc66, "Ugly": 0xcc6666}</option>
Example chart:
The "trick": For each day, calculate values for Good, Bad, and Ugly. Only specify a value for the applicable field; leave the other two null. For example, If a value is "Good", leave the Bad and Ugly fields null. Each day will have only a Good, Bad, or Ugly value. Stack these field values. Each stack will have only a single value, with the appropriate color.
Nit: The data value appears inside the bar rather than on top. This is a consequence of stacking. Sorry.
... View more