LoginSignup
1
1

More than 3 years have passed since last update.

selfjoin

Posted at

selfjoin@Splunk>docs

説明

指定した1つ以上のフィールドに基づいて、検索結果行を同じ結果セット内の他の検索結果行と結合します。

記述方法

selfjoin [<selfjoin-options>...] <field-list>

引数

<field-list>

結合したいフィールド

オプション引数

overwrite=<bool>とmax=<int>

join参照

keepsingle=<bool>

base.spl
| makeresults 
| eval _raw="id name    owner_id
1   aka 1
2   ao  2
3   shiro   1
4   kuro    4" 
| multikv forceheader=1 
| table id name owner_id 
| append
    [|makeresults
    | eval _raw="id name
1   ichiro
2   jiro
3   saburo" 
    | multikv forceheader=1 
    | table id name]
id name owner_id
1 aka 1
2 ao 2
3 shiro 1
4 kuro 4
1 ichiro
2 jiro
3 saburo

keepsingle=true

keepsingle_t.spl
....
| selfjoin keepsingle=t id
id name owner_id
1 aka 1
2 ao 2
3 shiro 1
4 kuro 4

keepsingle=false

keepsingle_f.spl
....
| selfjoin keepsingle=f id
id name owner_id
1 aka 1
2 ao 2
3 shiro 1

デフォルトはfalse

使用方法

1時間ごとの集計の間に各5分間の数値をあいだに入れた表。

selfjoin.spl
index=_internal sourcetype=splunkd
| bin span=10m _time
| eval timeA= _time
| bin span=1h _time
| eval timeB= _time
| multireport [ chart count as count5m by source timeA]
[ chart count as count1h by source timeB]
| foreach 15* [ eval time_<<FIELD>>=strftime("<<FIELD>>","%T")
| eval {time_<<FIELD>>} = '<<FIELD>>'
| fields - <<FIELD>> time_<<FIELD>>]
| selfjoin source

appendとかappedpipeでつくった行をさっとくっつけるのに使用するselfjoin
2行しかくっつけられないのでそれだけ注意すると、こんなこともできます。
multireportはSplunk>docsに載っていないけど、動作としてはこんな感じで二つの集計を走らせることができます。

まとめ

表を軽く、くっつけることができるselfjoin
appendpipeappendで2つの行をつくった時、くっつけるならこのコマンドを思い出してやってください。

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