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!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

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