毎日9時と21時に12時間以内に取り込んだデータから該当するモノがあった場合メールを送るようなアラートを想定しています。
その際の検索条件なのですがローカルファイルにある対象製品リストから製品名を取得し検索を掛ける事は可能でしょうか?
また製品リストは複数あり、それぞれメール送信先を分けたいと考えています。
上手い実装方法が思いついていないのですがScriptなどを作らないと対応出来ないのでしょうか。
English translation:
We assume an alert such as sending an e-mail if there is a corresponding item from the data captured within 12 hours at 9 o'clock and 21 o'clock every day.
It is a search condition at that time, but is it possible to retrieve the product name from the target product list in the local file and search it?
There are two or more product lists, and we would like to separate the mail transmission destination respectively.
I do not think of a good implementation method, but can not we cope without having to create Script etc?
こんにちは。
製品リストがCSVであれば、inputlookupを使うのはいかがでしょうか。
ProductA.csv
----
product_name <-CSVヘッダ(フィールド名)
Product1
Product2
Product3
というCSVがあり、
・Splunk内のデータで製品名がproduct_nameに格納されている
・myindexというindexにデータは格納されている
場合、以下のようにjoinを使うとCSV内にある製品名の情報だけが取得できます。
| inputlookup ProductA.csv | join product_name [ search index=myindex ]
アラートですが、複数の製品リストがある(=ファイルが分けられている)、送信先が異なる、という話であれば素直に別々のアラートとして定義したほうが楽だと思います。
たとえば
Product A用のアラートのクエリ:
| inputlookup ProductA.csv | join product_name [ search index=myindex ]
Product B用のアラートのクエリ:
| inputlookup ProductB.csv | join product_name [ search index=myindex ]
といった感じです。
こんにちは。
製品リストがCSVであれば、inputlookupを使うのはいかがでしょうか。
ProductA.csv
----
product_name <-CSVヘッダ(フィールド名)
Product1
Product2
Product3
というCSVがあり、
・Splunk内のデータで製品名がproduct_nameに格納されている
・myindexというindexにデータは格納されている
場合、以下のようにjoinを使うとCSV内にある製品名の情報だけが取得できます。
| inputlookup ProductA.csv | join product_name [ search index=myindex ]
アラートですが、複数の製品リストがある(=ファイルが分けられている)、送信先が異なる、という話であれば素直に別々のアラートとして定義したほうが楽だと思います。
たとえば
Product A用のアラートのクエリ:
| inputlookup ProductA.csv | join product_name [ search index=myindex ]
Product B用のアラートのクエリ:
| inputlookup ProductB.csv | join product_name [ search index=myindex ]
といった感じです。
回答ありがとうございます。
| inputlookup ProductA.csv | join product_name [ search index=myindex ]
このコマンドで試してみたところ1製品に対して結果が1つしか返ってこないようです。
(例えば index=myindex product_name = Product1 で検索した場合,他のカラムである番号や日時が違うモノなど、全てのイベントを含めて100件以上の結果が返ってくるが、例のサーチ文だと1件のみ結果として出力されている。)
原因や対策など何かありますでしょうか。
すいません、joinはデフォルトでは1つの結果しか返さないのでした。次のように、結果を返す数を0(=無制限)にしてみるといかがでしょうか。
| inputlookup ProductA.csv | join max=0 product_name [ search index=myindex ]
こちらのjoinのオプション確認漏れのようで申し訳ありません、max=0のオプションを付け足す事で想定通りに動きました!
ありがとうございました!
I'm using google translate to try and answer this, so hopefully it makes sense.
You can use result tokens in the email address field.
| eval to_email=case(product=type1,"blaku@example",product=type2,"email2@example"
Then in the alert action Send Email , To field: $result.to_email$
@anthonymelita
Thank you!!
Probably will work