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!

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