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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...