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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...