Alerting

動的なアラート条件は作れますか? Can I create dynamic alert conditions?

blaku
Explorer

毎日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?

0 Karma
1 Solution

yeguchi
Explorer

こんにちは。
製品リストが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 ]

といった感じです。

View solution in original post

yeguchi
Explorer

こんにちは。
製品リストが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 ]

といった感じです。

blaku
Explorer

回答ありがとうございます。
| inputlookup ProductA.csv | join product_name [ search index=myindex ]
このコマンドで試してみたところ1製品に対して結果が1つしか返ってこないようです。

(例えば index=myindex product_name = Product1 で検索した場合,他のカラムである番号や日時が違うモノなど、全てのイベントを含めて100件以上の結果が返ってくるが、例のサーチ文だと1件のみ結果として出力されている。)
原因や対策など何かありますでしょうか。

0 Karma

yeguchi
Explorer

すいません、joinはデフォルトでは1つの結果しか返さないのでした。次のように、結果を返す数を0(=無制限)にしてみるといかがでしょうか。

| inputlookup ProductA.csv | join max=0 product_name [ search index=myindex ]

blaku
Explorer

こちらのjoinのオプション確認漏れのようで申し訳ありません、max=0のオプションを付け足す事で想定通りに動きました!
ありがとうございました!

0 Karma

anthonymelita
Contributor

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$

blaku
Explorer

@anthonymelita
Thank you!!
Probably will work

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...