Splunk Search

親IDと子が持つ親IDが一致している場合に子にデータを追加する方法

1014502
New Member

お世話になります。
以下のようなデータがあります。

Index A(工数データ)
    id,issue.id,man-hour
    a c 2

Index B(チケットデータ)
    issue.id,parent.id,type,subject
    b null 111 null
    c b null test

以下のように結果を出力したいです。
id,type,subject,man-hour
c 111 test 2
インデックスBは親チケット情報と子チケット情報があり、子チケットには親のIDを持っています。

0 Karma

to4kawa
Ultra Champion
index=A  OR index=B
| eval parent.id = coalesce(id, 'parent.id', 'issue.id') 
| eval issue.id = nullif('issue.id','parent.id') 
| stats values(id) as id values(issue.id) as issue.id values(type) as type values(subject) as subject values(man-hour) as man-hour by parent.id 
| fields - parent.id 
| selfjoin issue.id 
| table id,type,subject,man-hour

こんにちは

動かしてないので間違いがあるかもしれませんが、こちらでどうでしょう?

| makeresults 
| eval _raw="id,issue.id,parent.id,type,subject,man-hour
a,c,,,,2
,b,,111,,
,c,b,,test," 
| multikv forceheader=1 
| rename issue_id as issue.id parent_id as parent.id, man_hour as man-hour 
| table id,issue.id,parent.id,type,subject,man-hour 
| eval parent.id = coalesce(id, 'parent.id', 'issue.id') 
| eval issue.id = nullif('issue.id','parent.id') 
| stats values(id) as id values(issue.id) as issue.id values(type) as type values(subject) as subject values(man-hour) as man-hour by parent.id 
| fields - parent.id 
| selfjoin issue.id 
| table id,type,subject,man-hour

確認しました。フィールドをシングルコーテーションで囲わないとうまくいかなかったですね。
修正しています。

0 Karma

1014502
New Member

This is my current search:
index=A
|join type=left issue.id
[search index=B
|join type=outer
[search indexB]
|where parent.id = issue.id]

0 Karma

1014502
New Member

インデックスAはインデックスBのチケットについている工数情報です。
インデックスBはチケット情報です。
さらに、インデックスBは親チケットと子チケットのがあり、子チケットには親チケットのIDを持っています。
子チケットの親IDが親チケットの親IDと一致している場合は、子チケットに親チケットの情報を追加したいです。

0 Karma

melonman
Motivator

Hi @1014502 ,
You put "japanese" tag to this question. If you want, please write your question in Japanese 🙂

0 Karma

1014502
New Member

異なるインデックスAとBのデータを紐づけ、データを抽出したいです。
Aは工数情報のデータになっています。
Bのデータはチケット情報になっています。
さらに、Bは親と子の関係になっているおり、子には親のIDを持っているため、子がもつ親IDと親チケット情報のIDが一致している場合は、子のチケット情報に親の情報を結合させたいです。

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...