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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...