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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...