| 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 | # File 'lib/internet_box_logger/elastic_search.rb', line 42
def save
  internal_representation = []
  EasyAppHelper.logger.debug 'Saving measurements to ElasticSearch'
  self.as_es_documents.each do |document|
    begin
      EasyAppHelper.logger.debug " - #{document[:body][:name]}"
      internal_representation << elasticsearch_client.index(**document)
    rescue => e
      EasyAppHelper.logger.error e.message
    end
  end
  @internal_es_representation = internal_representation
  EasyAppHelper.puts_and_logs 'Your box metrics have been indexed into Elastic Search'
  self
rescue
  EasyAppHelper.logger.error 'Unable to save to ElasticSearch !!'
end |