Splunk Search

クロス集計表でパーセント表記をさせたい

taroito1q75
New Member

contingencyコマンドを使えばクロス集計表(左図)が得られますが、これをパーセント表記させる(右図)方法はありますでしょうか?
alt text

0 Karma

melonman
Motivator

以下のようにcontingencyの結果(usetotal=fを利用)から%を計算させるやり方です。(
*f1, f2は実際のフィールド名に置き換えていただければ。
*他にも色々あるとおもいますが、まずは一案として投函します。

<your search> ...
 | contingency f1 f2 usetotal=f
 | untable f1 f2 v
 | eventstats sum(v) as total
 | eval perc_v=round(100*v/total)
 | xyseries f1 f2 perc_v
 | addcoltotals labelfield=f1 label=Total
 | addtotals fieldname=Total

結果

alt text

%を最後に足しちゃっているので、Totalで101%とかでてきちゃうかもしれませんが、あとは煮るなり焼くなりしていただければとおもいます。

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

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, ...