Getting Data In

ファイル名に含まれている日付をタイムスタンプとして認識させる方法について

tkmq
New Member

ファイル名に日付、ログに時刻のみ出力されている場合、
「ファイル名の日付+ログ内の時刻」をタイムスタンプとして認識させることはできますか?

・ファイル名
/tmp/test_2015.01.01.txt

・ログ
line1 00:31:05
line2 00:31:10
line3 00:37:49

Tags (2)
0 Karma
1 Solution

jkat54
SplunkTrust
SplunkTrust

はい

あなたはこのようなソースフィールドから日付を抽出します。

| rex field=source "(?<date>\d\d\d\d\.\d\d\.\d\d)"

次に、このようなイベントから時間が抽出されます:

| rex field=_raw "(?<time>\d\d:\d\d:\d\d)"

次に、このように一つのフィールドにフィールドを結合します。

| eval datetimestamp=date." ".time

次に、このようなフィールドdatetimestampを表示します。

| table datetimestamp

この検索で終わるだろう。

...
| rex field=source "(?<date>\d\d\d\d\.\d\d\.\d\d)"
| rex field=_raw "(?<time>\d\d:\d\d:\d\d)"
| eval datetimestamp=date." ".time
| table datetimestamp

あなたはprops.confで同じ抽出を行うことができます。

EXTRACT-date = "(?<date>\d\d\d\d\.\d\d\.\d\d)" in source
EXTRACT-time = "(?<time>\d\d:\d\d:\d\d)" in _raw

View solution in original post

jkat54
SplunkTrust
SplunkTrust

はい

あなたはこのようなソースフィールドから日付を抽出します。

| rex field=source "(?<date>\d\d\d\d\.\d\d\.\d\d)"

次に、このようなイベントから時間が抽出されます:

| rex field=_raw "(?<time>\d\d:\d\d:\d\d)"

次に、このように一つのフィールドにフィールドを結合します。

| eval datetimestamp=date." ".time

次に、このようなフィールドdatetimestampを表示します。

| table datetimestamp

この検索で終わるだろう。

...
| rex field=source "(?<date>\d\d\d\d\.\d\d\.\d\d)"
| rex field=_raw "(?<time>\d\d:\d\d:\d\d)"
| eval datetimestamp=date." ".time
| table datetimestamp

あなたはprops.confで同じ抽出を行うことができます。

EXTRACT-date = "(?<date>\d\d\d\d\.\d\d\.\d\d)" in source
EXTRACT-time = "(?<time>\d\d:\d\d:\d\d)" in _raw
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 ...