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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...