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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...