Splunk Search

LookUpでカレンダー情報を作り、該当日のサーチ範囲を指定したい。

enoshima
New Member

例えば、Index=XXX sourcetype=+++ と言ったログファイルをサーチする際に

2018/09/10には2018/9/7のデータを検索したい、2018/09/11には2018/09/08~2018/09/10までのデータを検索したい
と言う様に、サーチの実施日によって検索範囲を変えるサーチ文はどの様に実現出来ますでしょうか?

例えば、下記の様なCSV形式のファイルを作成して、LookUpなどで参照して、where分などでログを絞り込むと言った
事が出来ないかと考えたのですが、どの様なサーチ文を書けばよいのでしょうか?

何らかのカレンダーデータを参照する事になるとは思っていますが、良いやり方があればご教授願います。

date,start_dat,end_day
2018/09/10,2018/09/07,2018/09/07
2018/09/11,2018/09/08,2018/09/10
2018/09/12,2018/09/11,2018/09/11

0 Karma

tuemura_splunk
Splunk Employee
Splunk Employee

starttime と endtimeをサブサーチに返してもらうことで意図した結果になるのではないでしょうか。
以下、SPLサンプルです。
記載されたcsvデータをcal という名前でlookup定義しています。

index=_internal timeformat=%Y/%m/%d 
    [| inputlookup cal 
    | where date = strftime(now(),"%Y/%m/%d")
    | rename start_dat as starttime, end_day as endtime 
    | return starttime endtime]
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...