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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...