0
0

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 5 years have passed since last update.

Splunk SPL 複数イベントの属性を集約して1イベントにまとめたい

Last updated at Posted at 2019-10-23

#1 こんなデータ

  • FieldA と FieldB の列を持つ
  • FieldA の属性が FieldB にもつが、イベント(行)ごとに分かれている
  • FieldA で集約して、1イベントに複数属性をもたせたい

image.png

#2 それをこうしたい
image.png

  • 集約したFieldA ごとに各FieldBの属性を並べて表示

#3 データ取り込んでみた
image.png

テーブル化
image.png

#4 SPLで編集して整形
image.png

source="test.csv" host="test" index="test" sourcetype="csv"
| table FieldA,FieldB
| stats values(FieldB) as values by FieldA
| eval  FieldC=if(isnotnull(mvfind(values,"監督")),"監督","")
| eval  FieldD=if(isnotnull(mvfind(values,"選手")),"選手","")
| eval  FieldE=if(isnotnull(mvfind(values,"コーチ")),"コーチ","")
| table FieldA,FieldC,FieldD,FieldE
  • まず stats values by でFieldAごとにマルチバリュー(mv)で集約する
  • mvfind()で mvに含まれている文字列がnullでなければ、その文字列を新規Filed に挿入
  • table で整形
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?