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!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...