@@ -190,6 +190,19 @@ def build_events_list(events)
190190 # @api private
191191 def resource_status_to_hash ( resource_status )
192192 defaulted_corrective_change = defined? ( resource_status . corrective_change ) ? resource_status . corrective_change : nil
193+ index_size = resource_event_index_size ( resource_status )
194+
195+ if index_size > 2500 && index_size <= 2704
196+ Puppet . warning ( "resource_event on #{ self . host } is very large. Values (resource timestamp + title + type) \
197+ are #{ index_size } bytes and the hard limit is 2704. Caused by Resource type: \" #{ resource_status . resource_type } \" \
198+ with title: \" #{ resource_status . title . to_s } \" in #{ resource_status . file } :#{ resource_status . line } ")
199+ end
200+
201+ if index_size > 2704
202+ Puppet . warning ( "resource_event on #{ self . host } could not be saved. Values (resource timestamp + title + type) are larger \
203+ than index total size of 2704. Caused by Resource type: \" #{ resource_status . resource_type } \" with title: \
204+ \" #{ resource_status . title . to_s } \" in #{ resource_status . file } :#{ resource_status . line } ")
205+ end
193206 {
194207 "skipped" => resource_status . skipped ,
195208 "timestamp" => Puppet ::Util ::Puppetdb . to_wire_time ( resource_status . time ) ,
@@ -203,6 +216,17 @@ def resource_status_to_hash(resource_status)
203216 }
204217 end
205218
219+ # Get the size of the columns that will populate the resource_events_resource_timestamp_xxxxxz index.
220+ # resource_events_resource_timestamp_xxxxxz index is comprised of 3 columns (resource timestamp, title and type)
221+ # and it's maximum size is 2704 bytes. So the size of the 3 resource attributes combined, must not exceed 2704 bytes.
222+ #
223+ # @return Boolean
224+ # @api private
225+ def resource_event_index_size ( resource_status )
226+ # 8 - represents the timestamp which has the same size all the time
227+ 8 + resource_status . resource_type . bytesize + resource_status . title . to_s . bytesize
228+ end
229+
206230 # Helper method for accessing the puppetdb configuration
207231 #
208232 # @api private
0 commit comments