0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Splunk: 計算済みフィールドの使い方

Posted at
実施環境: Splunk Free 8.2.2

Splunk での検索において、あるフィールドをそのままではなく加工して扱いたい場合があります。
eval コマンドを使用すれば加工はできますが、実はコマンドを使用しなくともフィールドを加工して利用できる機能があります。
それが今回紹介する、計算済みフィールド( calculated fields )という機能です。

1. 概要

例えば、ログ A において キロバイト単位で値が出力されるフィールド B があるとします。

このフィールド B についてギガバイト単位で値を扱いたい場合、値を1024で割ったフィールド C を作成すればギガバイト単位になります。

eval コマンドを利用すればこのような操作ができますが、これをコマンドなしで実現するのが計算済みフィールドという機能です。

2. 設定方法

「設定」⇒「フィールド」を選択します。

WS000536.JPG

「計算済みフィールド」を選択します。

WS000544.JPG

計算済みフィールドの一覧画面が開くので、右上の「新しい計算済みフィールド」を選択します。

WS000545.JPG

計算済みフィールドの設定を入力します。

WS000566.JPG

ここでは以下の設定を入力します。
Eval 式には、演算子だけでなく任意の評価関数( eval 関数, Evaluation functions )も使用可能です。

項目名
宛先 App search
適用先 ソース
名前付き /opt/splunk/var/log/splunk/metrics.log
名前 calc_gb
Eval 式 round(kb / 1024, 2)

これで計算済みフィールドが作成できました。

WS000570.JPG

3. 使用方法

試しに、以下の SPL で計算済みフィールドを使用してみましょう。

Splunk
index="_internal" source="*metrics.log" group=thruput name=thruput
| stats max(kb), max(calc_gb)

WS000571.JPG

計算されたフィールド名calc_gbが存在していることがわかります。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?