Dashboards & Visualizations

Pie チャートで小数点第二位まで表示する方法

CurryPan
Communicator

Pie チャートで下記のように simple XML でパーセント表示を有効にすると、小数点第三位まで表示されてしまいます。

<query>index=* | stats count by sourcetype </query>
<option name="charting.chart.showPercent">1</option>

alt text

四捨五入して小数点第二位まで表示する方法をご教示ください。

0 Karma
1 Solution

CurryPan
Communicator

下記のように、query内で soucetype 毎に合計を算出し、統計に対して round関数 を適用することで小数点第二位まで表示することができます。

<query>index=* | stats count by sourcetype | eventstats sum(count) as total | eval percent=round((count/total)*100,2) | eval sourcetype=sourcetype.", ".percent."%"</query>

alt text

この場合、 <option name="charting.chart.showPercent">1</option> は sampleXML に追加する必要はありません。

View solution in original post

0 Karma

CurryPan
Communicator

下記のように、query内で soucetype 毎に合計を算出し、統計に対して round関数 を適用することで小数点第二位まで表示することができます。

<query>index=* | stats count by sourcetype | eventstats sum(count) as total | eval percent=round((count/total)*100,2) | eval sourcetype=sourcetype.", ".percent."%"</query>

alt text

この場合、 <option name="charting.chart.showPercent">1</option> は sampleXML に追加する必要はありません。

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...