<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [Time Extraction] EventTime extraction for log file with event  having different time fileds in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Time-Extraction-EventTime-extraction-for-log-file-with-event/m-p/415963#M73501</link>
    <description>&lt;P&gt;&lt;STRONG&gt;1. Props.conf Configuration&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;[json_two_timeformat]&lt;BR /&gt;
INDEXED_EXTRACTIONS = json&lt;BR /&gt;
SHOULD_LINEMERGE = false&lt;BR /&gt;
KV_MODE = none&lt;BR /&gt;
TIME_PREFIX = (\"time\":|\"logCreationTime\")&lt;BR /&gt;
MAX_TIMESTAMP_LOOKAHEAD = 1000&lt;BR /&gt;
DATETIME_CONFIG = /etc/system/local/datetime_json_three_timeformats.xml&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2. Create the etc/system/local/datetime_json_three_timeformats.xml&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!-- SPLUNK_HOME/etc/system/local/datetime_json_three_timeformats.xml --&amp;gt;

&amp;lt;datetime&amp;gt;

&amp;lt;define name="_utcepoch_leg0" extract="utcepoch, subsecond"&amp;gt;
    &amp;lt;text&amp;gt;&amp;lt;![CDATA[\d{13},\s+.*? \"leg\":0, \"timestamp\":(\d{10})(\d{3})]]&amp;gt;&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;

&amp;lt;define name="_utcepoch_time" extract="utcepoch, subsecond"&amp;gt;
   &amp;lt;text&amp;gt;&amp;lt;![CDATA[(\d{10})(\d{3}), .* \"legs\":\[\]]]&amp;gt;&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;

&amp;lt;define name="logCreationTime" extract="year, month, day, hour, minute, second, subsecond"&amp;gt;
   &amp;lt;text&amp;gt;&amp;lt;![CDATA[(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})\.(\d{3})]]&amp;gt;&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;


&amp;lt;timePatterns&amp;gt;
    &amp;lt;use name="_utcepoch_leg0"/&amp;gt;
    &amp;lt;use name="_utcepoch_time"/&amp;gt;
    &amp;lt;use name="logCreationTime"/&amp;gt;
&amp;lt;/timePatterns&amp;gt;
&amp;lt;datePatterns&amp;gt;
    &amp;lt;use name="_utcepoch_leg0"/&amp;gt;
    &amp;lt;use name="_utcepoch_time"/&amp;gt;
    &amp;lt;use name="logCreationTime"/&amp;gt;
&amp;lt;/datePatterns&amp;gt;


&amp;lt;/datetime&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;```&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;3. Restart splunk&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;4. Ingest sample files&lt;/STRONG&gt;&lt;BR /&gt;
$SPLUNK_HOME/bin/splunk add oneshot json_two_timeformat.log -sourcetype json_two_timeformat&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;5. Results:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;$ ./bin/splunk search "index=test01 sourcetype=json_two_timeformat | spath path=legs{}.timestamp output=legs_timestamp | eval legs0_timestamp=mvindex(legs_timestamp, 0) | eval T=_time | table _time T legs0_timestamp time"&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:51:27 GMT</pubDate>
    <dc:creator>rbal_splunk</dc:creator>
    <dc:date>2020-09-29T22:51:27Z</dc:date>
    <item>
      <title>[Time Extraction] EventTime extraction for log file with event  having different time fileds</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Time-Extraction-EventTime-extraction-for-log-file-with-event/m-p/415962#M73500</link>
      <description>&lt;P&gt;In one log file, we have  data format that different for Event time:&lt;/P&gt;

&lt;P&gt;i) For this we would like "time":1544476509062  to be extracted as the event type:&lt;/P&gt;

&lt;P&gt;{"type":"transaction", "time":1544476509062, "path":"/healthcheckbalance", "protocol":"https", "protocolSrc":"8075", "duration":0, "status":"success", "serviceContexts":[], "customMsgAtts":{}, "correlationId":"5dd70e5ca4224df8175513e2", "legs":[]}&lt;/P&gt;

&lt;P&gt;ii) For this  we need to exatract event date from  "leg":0, "timestamp":1544476508996&lt;/P&gt;

&lt;P&gt;{"type":"transaction", "time":1544476509047, "path":"/creditos/v1/lis", "protocol":"https", "protocolSrc":"8065", "duration":51, "status":"success", "serviceContexts":[{"service":"creditos", "monitor":true, "client":"28ebc792-a5fa-4ec7-b2e4-fe3a98c7d52c", "org":"Canais_Internos", "app":"Super App", "method":"GET /lis", "status":"success", "duration":29}], "customMsgAtts":{}, "correlationId":"5cd70e5c9c22d31f411c8a9d", "legs":[{"uri":"/creditos/v1/lis", "status":200, "statustext":"OK", "method":"GET", "vhost":null, "wafStatus":0, "bytesSent":755, "bytesReceived":1014, "remoteName":"10.28.67.235", "remoteAddr":"10.28.67.235", "localAddr":"10.28.72.157", "remotePort":"37672", "localPort":"8065", "sslsubject":null, "leg":0, "timestamp":1544476508996, "duration":51, "serviceName":"creditos", "subject":"28ebc792-a5fa-4ec7-b2e4-fe3a98c7d52c", "operation":"GET /lis", "type":"http", "finalStatus":"Pass"}, {"uri":"/creditos/v1/lis", "status":200, "statustext":"OK", "method":"GET", "vhost":null, "wafStatus":0, "bytesSent":1043, "bytesReceived":873, "remoteName":"172.16.88.66", "remoteAddr":"172.16.88.66", "localAddr":"10.28.72.157", "remotePort":"80", "localPort":"40090", "sslsubject":null, "leg":1, "timestamp":1544476509019, "duration":27, "serviceName":"creditos", "subject":"28ebc792-a5fa-4ec7-b2e4-fe3a98c7d52c", "operation":"GET /lis", "type":"http", "finalStatus":null}]}&lt;/P&gt;

&lt;P&gt;iii) Eventtime will be as per  "logCreationTime":"2018-12-10 19:15:02.283"&lt;BR /&gt;
{"type":"header", "logCreationTime":"2018-12-10 19:15:02.283", "hostname":"fa163e4631ael03.ctmm1.prod.cloud.ihf", "domainId":"330f4a77-989c-4f70-8184-8f6a2ca44da9", "groupId":"group-2", "groupName":"GtwInterno", "serviceId":"instance-100", "serviceName":"GtwInstance_28_72_157", "version":"v7.5.3-Internal"}&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:51:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Time-Extraction-EventTime-extraction-for-log-file-with-event/m-p/415962#M73500</guid>
      <dc:creator>rbal_splunk</dc:creator>
      <dc:date>2020-09-29T22:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: [Time Extraction] EventTime extraction for log file with event  having different time fileds</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Time-Extraction-EventTime-extraction-for-log-file-with-event/m-p/415963#M73501</link>
      <description>&lt;P&gt;&lt;STRONG&gt;1. Props.conf Configuration&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;[json_two_timeformat]&lt;BR /&gt;
INDEXED_EXTRACTIONS = json&lt;BR /&gt;
SHOULD_LINEMERGE = false&lt;BR /&gt;
KV_MODE = none&lt;BR /&gt;
TIME_PREFIX = (\"time\":|\"logCreationTime\")&lt;BR /&gt;
MAX_TIMESTAMP_LOOKAHEAD = 1000&lt;BR /&gt;
DATETIME_CONFIG = /etc/system/local/datetime_json_three_timeformats.xml&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2. Create the etc/system/local/datetime_json_three_timeformats.xml&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!-- SPLUNK_HOME/etc/system/local/datetime_json_three_timeformats.xml --&amp;gt;

&amp;lt;datetime&amp;gt;

&amp;lt;define name="_utcepoch_leg0" extract="utcepoch, subsecond"&amp;gt;
    &amp;lt;text&amp;gt;&amp;lt;![CDATA[\d{13},\s+.*? \"leg\":0, \"timestamp\":(\d{10})(\d{3})]]&amp;gt;&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;

&amp;lt;define name="_utcepoch_time" extract="utcepoch, subsecond"&amp;gt;
   &amp;lt;text&amp;gt;&amp;lt;![CDATA[(\d{10})(\d{3}), .* \"legs\":\[\]]]&amp;gt;&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;

&amp;lt;define name="logCreationTime" extract="year, month, day, hour, minute, second, subsecond"&amp;gt;
   &amp;lt;text&amp;gt;&amp;lt;![CDATA[(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})\.(\d{3})]]&amp;gt;&amp;lt;/text&amp;gt;
&amp;lt;/define&amp;gt;


&amp;lt;timePatterns&amp;gt;
    &amp;lt;use name="_utcepoch_leg0"/&amp;gt;
    &amp;lt;use name="_utcepoch_time"/&amp;gt;
    &amp;lt;use name="logCreationTime"/&amp;gt;
&amp;lt;/timePatterns&amp;gt;
&amp;lt;datePatterns&amp;gt;
    &amp;lt;use name="_utcepoch_leg0"/&amp;gt;
    &amp;lt;use name="_utcepoch_time"/&amp;gt;
    &amp;lt;use name="logCreationTime"/&amp;gt;
&amp;lt;/datePatterns&amp;gt;


&amp;lt;/datetime&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;```&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;3. Restart splunk&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;4. Ingest sample files&lt;/STRONG&gt;&lt;BR /&gt;
$SPLUNK_HOME/bin/splunk add oneshot json_two_timeformat.log -sourcetype json_two_timeformat&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;5. Results:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;$ ./bin/splunk search "index=test01 sourcetype=json_two_timeformat | spath path=legs{}.timestamp output=legs_timestamp | eval legs0_timestamp=mvindex(legs_timestamp, 0) | eval T=_time | table _time T legs0_timestamp time"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:51:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Time-Extraction-EventTime-extraction-for-log-file-with-event/m-p/415963#M73501</guid>
      <dc:creator>rbal_splunk</dc:creator>
      <dc:date>2020-09-29T22:51:27Z</dc:date>
    </item>
  </channel>
</rss>

