Getting Data In

インデックス時にファイル名から時刻を取得する方法

yagi1234
New Member

ログファイル内に日付、時刻がなく、ファイル名に日付がある場合に、ファイル名の日付を_timeとして認識させることは可能でしょうか?
タイムレンジピッカーによる日付範囲指定を行いたいので、index-timeに_timeに値を設定したいと考えています。
※search-timeだとタイムレンジピッカーによる絞り込みが行えないため

・ログファイル名:ABC_20170203.csv
・期待する結果:
 _time=2017/02/03 00:00:00

0 Karma

felipesewaybric
Contributor

このファイルを編集することができます:datetime.xml
You can edit the file: datetime.xml

 <datetime>
 <define name="datefromfile" extract="year, month, day">
    <text><![CDATA[source::.*?_(\d{4})(\d{2})(\d{2}]]></text>
 </define>
 <define name="timefromfile" extract="hour, second">
    <text><![CDATA[source::.*?_\d{8}(\d{2})(\d{2}]]></text>
 </define>
 <timePatterns>
    <use name="timefromfile"/>
 </timePatterns>
 <datePatterns>
    <use name="datefromfile"/>
 </datePatterns>
 </datetime>
0 Karma

yagi1234
New Member

回答ありがとうございます。
以下条件で確認しましたが、うまく動作しません 。

※ファイル名を「ABC_20170105101501.csv」とし、ファイル名に年月日時分秒を設定しました。

datetime.xml

<datetime>
<define name="datefromfile" extract="year, month, day">
   <text><![CDATA[source::.*?_(\d{4})(\d{2})(\d{2})]]></text>
</define>
<define name="timefromfile" extract="hour, minute, second">
   <text><![CDATA[source::.*?_\d{8}(\d{2})(\d{2})(\d{2})]]></text>
</define>
<timePatterns>
   <use name="timefromfile"/>
</timePatterns>
<datePatterns>
   <use name="datefromfile"/>
</datePatterns>
</datetime>

props.conf
[samplecsv]

DATETIME_CONFIG = /etc/system/local/datetime.xml

ABC_20170105101501.csv

column1,column2,column3
a,b,c
d,e,f

結果
alt text

以上、よろしくお願いいたします。

0 Karma

felipesewaybric
Contributor

お役に立てて嬉しいです

0 Karma
Get Updates on the Splunk Community!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...