Getting Data In

Pie chart colors not changing when only one value

power12
Communicator

I have a query where I am counting the PASS and fail and displaying it as a pie-chart.Also I modified the search so that it displays the count and status .When the status field which has pass and fail values the pie chart displays green for pass and red for  fail as expected but when there is only pass it displays red not green

Attached is the screenshot

 

 

 

 <chart>
        <search>
          <query>index="abc"

| rex field=source "ame\/(?&lt;Type&gt;[^\/]+)" 
|search Type=$tok_type$
| rex field=_raw "(?i)^[^ ]* (?P&lt;status&gt;.+)" 
| stats latest(status) as status by host 
| stats count by status
 | eval chart = count + " " + status | fields chart, count</query>
          <earliest>$tok_time.earliest$</earliest>
          <latest>$tok_time.latest$</latest>
        </search>
        <option name="charting.chart">pie</option>
        <option name="charting.drilldown">none</option>
           <option name="charting.legend.labels">[FAIL,PASS]</option>
        <option name="charting.seriesColors">[#BA0F30,#116530]</option>
        <option name="refresh.display">progressbar</option>
        <option name="charting.chart.showPercent">true</option>
      </chart>

 

 

 

 

Thanks in Advance 

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

The problem that seriesColours is just a list of colours that are used in order, so if there are two rows, the FAIL row is always first, so the first colour in the series applies.

I believe the only way to solve this is by adding a <done> clause after the search to calculate what the series colours should be and then use the token, like this

<search>
...
  <done>
    <eval token="series_colour">case($job.resultCount$=2, "#BA0F30,#116530", $job.resultCount$=1 AND match($result.chart$,"FAIL"), "#BA0F30", $job.resultCount$=1 AND match($result.chart$,"PASS"), "#116530")</eval>
  </done>
</search>
...
<option name="charting.seriesColors">[$series_colour$]</option>

So, the eval part of the done clause will check if there are two rows, then the series has two values, otherwise it checks the chart field to see if it is FAIL or PASS and sets the single series values as appropriate.

Then in the seriesColors statement, use the token.

 

View solution in original post

0 Karma

power12
Communicator

@bowesmana  that worked thank you

0 Karma

bowesmana
SplunkTrust
SplunkTrust

The problem that seriesColours is just a list of colours that are used in order, so if there are two rows, the FAIL row is always first, so the first colour in the series applies.

I believe the only way to solve this is by adding a <done> clause after the search to calculate what the series colours should be and then use the token, like this

<search>
...
  <done>
    <eval token="series_colour">case($job.resultCount$=2, "#BA0F30,#116530", $job.resultCount$=1 AND match($result.chart$,"FAIL"), "#BA0F30", $job.resultCount$=1 AND match($result.chart$,"PASS"), "#116530")</eval>
  </done>
</search>
...
<option name="charting.seriesColors">[$series_colour$]</option>

So, the eval part of the done clause will check if there are two rows, then the series has two values, otherwise it checks the chart field to see if it is FAIL or PASS and sets the single series values as appropriate.

Then in the seriesColors statement, use the token.

 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...