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!

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