<?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>question Re: Nifi JsonRecordSetWriter help, timestamp field manipulation in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Nifi-JsonRecordSetWriter-help-timestamp-field-manipulation/m-p/330487#M230697</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/68942"&gt;@prova&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="p-rich_text_section"&gt;Based on timestamp shared, the source is RFC3164 syslog messages in which the timestamp does not include a year.&lt;BR /&gt;The SyslogReader supports both RFC3164 and RFC5424 syslog messages, but uses a generic syslog schema applied against the source data:&lt;/DIV&gt;&lt;PRE&gt;				{
				  "type" : "record",
				  "name" : "nifiRecord",
				  "namespace" : "org.apache.nifi",
				  "fields" : [ {
					"name" : "priority",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "severity",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "facility",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "version",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "timestamp",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "hostname",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "body",
					"type" : [ "null", "string" ]
				  } ]
				}&lt;/PRE&gt;&lt;DIV class="p-rich_text_section"&gt;You can see that timestamp is treated as a string.&lt;BR /&gt;&lt;BR /&gt;When it comes to reformatting the customer is looking for, where is NiFi expected to extract the year from since int is not in the syslog message?&lt;BR /&gt;&lt;BR /&gt;Since schema treats the timestamp as a string, it can't be treated like a timestamp type within the syslog for reformatting.This is possible with RFC5424 formatted source syslog messages.&lt;BR /&gt;&lt;BR /&gt;This is not to say that you could not manipulate this date string via some downstream processor, but would still need to figure out where you are going to get the year from.&amp;nbsp; NiFi can't assume that RFC3164 formatted syslog message was produced in same year that NiFi is parsing it.&amp;nbsp; This becomes hard to handle evening via some downstream processor at end of year where NiFi servers may already be in 2022 for example but received RFC3164 syslog messages were produced in 2021.&lt;BR /&gt;&lt;BR /&gt;RFC3164 was absolute when RFC5424 was introduced.&amp;nbsp; RFC3164 syslog messages are produced by older systems and the options here are limited.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV class="p-rich_text_section"&gt;&lt;P&gt;If you found this response assisted with your query, please take a moment to login and click on "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" below this post.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 18 Nov 2021 14:45:50 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2021-11-18T14:45:50Z</dc:date>
    <item>
      <title>Nifi JsonRecordSetWriter help, timestamp field manipulation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-JsonRecordSetWriter-help-timestamp-field-manipulation/m-p/330306#M230638</link>
      <description>&lt;P&gt;I'm trying to use a&amp;nbsp;&lt;SPAN&gt;ListenUDPRecord processor to parse syslog messages as input, using&amp;nbsp;SyslogReader as&amp;nbsp;Record Reader and&amp;nbsp;JsonRecordSetWriter as&amp;nbsp;Record Writer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The solution is working as I am getting a json message as output with the following fields:&amp;nbsp;priority,&amp;nbsp;severity,&amp;nbsp;facility,&amp;nbsp;version,&amp;nbsp;timestamp,&amp;nbsp;hostname,&amp;nbsp;body.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The json must then be indexed in a solr collection and the problem is that I get a timestamp field of the form:&amp;nbsp;Nov 16 12:36:32 but I would need a unix timestamp fomat field (e.g.&amp;nbsp;1637062592000) or an output like that: "&lt;SPAN&gt;2021-11-16 12:36:32".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried to specify the&amp;nbsp;"Timestamp Format" field of the&amp;nbsp;JsonRecordSetWriter service (i.e.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"yyyy-MM-dd HH:mm:ss" or "MM/dd/yyyy HH:mm:ss") but output does not change.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can I change the structure of the timestamp field of my output json message?&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="http://community.cloudera.com/t5/image/serverpage/image-id/39795i478F5E272CAB02F2/image-size/large?v=v2&amp;amp;px=999" border="0" alt="Screenshot 2021-11-16 130326.png" title="Screenshot 2021-11-16 130326.png" /&gt;&lt;IMG src="http://community.cloudera.com/t5/image/serverpage/image-id/39796iB80A581092B7282C/image-size/large?v=v2&amp;amp;px=999" border="0" alt="Screenshot 2021-11-16 130258.png" title="Screenshot 2021-11-16 130258.png" /&gt;</description>
      <pubDate>Tue, 16 Nov 2021 12:07:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-JsonRecordSetWriter-help-timestamp-field-manipulation/m-p/330306#M230638</guid>
      <dc:creator>prova</dc:creator>
      <dc:date>2021-11-16T12:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi JsonRecordSetWriter help, timestamp field manipulation</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-JsonRecordSetWriter-help-timestamp-field-manipulation/m-p/330487#M230697</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/68942"&gt;@prova&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="p-rich_text_section"&gt;Based on timestamp shared, the source is RFC3164 syslog messages in which the timestamp does not include a year.&lt;BR /&gt;The SyslogReader supports both RFC3164 and RFC5424 syslog messages, but uses a generic syslog schema applied against the source data:&lt;/DIV&gt;&lt;PRE&gt;				{
				  "type" : "record",
				  "name" : "nifiRecord",
				  "namespace" : "org.apache.nifi",
				  "fields" : [ {
					"name" : "priority",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "severity",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "facility",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "version",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "timestamp",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "hostname",
					"type" : [ "null", "string" ]
				  }, {
					"name" : "body",
					"type" : [ "null", "string" ]
				  } ]
				}&lt;/PRE&gt;&lt;DIV class="p-rich_text_section"&gt;You can see that timestamp is treated as a string.&lt;BR /&gt;&lt;BR /&gt;When it comes to reformatting the customer is looking for, where is NiFi expected to extract the year from since int is not in the syslog message?&lt;BR /&gt;&lt;BR /&gt;Since schema treats the timestamp as a string, it can't be treated like a timestamp type within the syslog for reformatting.This is possible with RFC5424 formatted source syslog messages.&lt;BR /&gt;&lt;BR /&gt;This is not to say that you could not manipulate this date string via some downstream processor, but would still need to figure out where you are going to get the year from.&amp;nbsp; NiFi can't assume that RFC3164 formatted syslog message was produced in same year that NiFi is parsing it.&amp;nbsp; This becomes hard to handle evening via some downstream processor at end of year where NiFi servers may already be in 2022 for example but received RFC3164 syslog messages were produced in 2021.&lt;BR /&gt;&lt;BR /&gt;RFC3164 was absolute when RFC5424 was introduced.&amp;nbsp; RFC3164 syslog messages are produced by older systems and the options here are limited.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV class="p-rich_text_section"&gt;&lt;P&gt;If you found this response assisted with your query, please take a moment to login and click on "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" below this post.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Nov 2021 14:45:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-JsonRecordSetWriter-help-timestamp-field-manipulation/m-p/330487#M230697</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2021-11-18T14:45:50Z</dc:date>
    </item>
  </channel>
</rss>

