<?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 Extract timestamp from two json fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-timestamp-from-two-json-fields/m-p/680887#M113756</link>
    <description>&lt;P&gt;I need to extract timestamp from a JSON log where date and time are on two separate fields. Example below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{  "Date": 240315, "EMVFallback": false, "FunctionCode": 80, "Time": 154915 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date here is equivalent of 2024-March-15 and the time is 15:49:15 pm.&lt;/P&gt;&lt;P&gt;I am struggling to find a way to extract timestamp using props.conf. May you please assist.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2024 21:43:23 GMT</pubDate>
    <dc:creator>alec_stan</dc:creator>
    <dc:date>2024-03-15T21:43:23Z</dc:date>
    <item>
      <title>Extract timestamp from two json fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-timestamp-from-two-json-fields/m-p/680887#M113756</link>
      <description>&lt;P&gt;I need to extract timestamp from a JSON log where date and time are on two separate fields. Example below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{  "Date": 240315, "EMVFallback": false, "FunctionCode": 80, "Time": 154915 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date here is equivalent of 2024-March-15 and the time is 15:49:15 pm.&lt;/P&gt;&lt;P&gt;I am struggling to find a way to extract timestamp using props.conf. May you please assist.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 21:43:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-timestamp-from-two-json-fields/m-p/680887#M113756</guid>
      <dc:creator>alec_stan</dc:creator>
      <dc:date>2024-03-15T21:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extract timestamp from two json fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-timestamp-from-two-json-fields/m-p/680911#M113760</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/265979"&gt;@alec_stan&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can extract the timestamp using INGEST_EVAL in transforms.conf referenced by a TRANSFORMS setting in props.conf.&lt;/P&gt;&lt;P&gt;If your source type has INDEXED_EXTRACTIONS = json, you can reference the Date and Time fields directly in your INGEST_EVAL expression; otherwise, you can use JSON eval functions to extract the Date and Time values from _raw.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;### with INDEXED_EXTRACTIONS

# props.conf

[alec_stan_json]
INDEXED_EXTRACTIONS = json
TRANSFORMS-alec_stan_json_time = alec_stan_json_time

# transforms.conf

[alec_stan_json_time]
INGEST_EVAL = _time:=strptime(tostring(Date).tostring(Time), "%y%m%d%H%M%S")

### without INDEXED_EXTRACTIONS

# props.conf

[alec_stan_json]
TRANSFORMS-alec_stan_json_time = alec_stan_json_time

# transforms.conf

[alec_stan_json_time]
INGEST_EVAL = _time:=strptime(tostring(json_extract(json(_raw), "Date")).tostring(json_extract(json(_raw), "Time")), "%y%m%d%H%M%S")&lt;/LI-CODE&gt;&lt;P&gt;If the event time zone differs from the receiver time zone, add a time zone string (%Z) or offset (%z) to the eval expression:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[alec_stan_json_time]
INGEST_EVAL = _time:=strptime(tostring(Date).tostring(Time)."EDT", "%y%m%d%H%M%S%Z")&lt;/LI-CODE&gt;&lt;P&gt;In a typical environment, deploy props.conf to universal forwarders and props.conf and transforms.conf to receivers (heavy forwarders and indexers).&lt;/P&gt;&lt;P&gt;If you haven't already, you should add SHOULD_LINEMERGE, LINE_BREAKER, etc. settings to props.conf to correctly break your input into events. You can also set DATETIME_CONFIG = CURRENT or DATETIME_CONFIG = NONE to help Splunk skip automatic timestamp extraction logic since you'll be extracting the timestamp using INGEST_EVAL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Mar 2024 16:45:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-timestamp-from-two-json-fields/m-p/680911#M113760</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2024-03-16T16:45:11Z</dc:date>
    </item>
  </channel>
</rss>

