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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...