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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...