Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
InfluxDB Cap and U metrics
diff --git a/Gemfile b/Gemfile
index 90b36f7..75077b4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,6 +4,8 @@ eval_gemfile(File.expand_path("gems/pending/Gemfile", __dir__))
# VMDB specific gems
#
+gem 'influxdb'
+
gem "activerecord-deprecated_finders", "~>1.0.4", :require => "active_record/deprecated_finders"
gem "rails", "~>4.2.3"
diff --git a/app/models/metric/ci_mixin/processing.rb b/app/models/metric/ci_mixin/processing.rb
index d655915..2b98cfd 100644
--- a/app/models/metric/ci_mixin/processing.rb
+++ b/app/models/metric/ci_mixin/processing.rb
@@ -56,6 +56,18 @@ module Metric::CiMixin::Processing
end
end
+ $influxdb ||= InfluxDB::Client.new "vmdb_development"
+ rt_rows.each do |ts, rt|
+ rt = rt.except(*%i(capture_interval_name capture_interval resource_name timestamp instance_id class_name))
+ data = {
+ :timestamp => (Time.parse(ts).to_f * 1000).to_i,
+ :tags => {:class_name => self.class.name, :instance_id => id},
+ :values => rt
+ }
+ puts "WRITING: #{data}"
+ $influxdb.write_point("metrics", data, "ms")
+ end
+
# Read all the existing perfs for this time range to speed up lookups
obj_perfs, = Benchmark.realtime_block(:db_find_prev_perfs) do
Metric::Finders.hash_by_capture_interval_name_and_timestamp(self, start_time, end_time, interval_name)
> Vm.where(:power_state => "on").each { |v| v.perf_capture("realtime") }
SELECT * FROM metrics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.