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!

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 ...