Last active
November 6, 2015 21:15
-
-
Save Fryguy/313c4ec36e2228f3b2c3 to your computer and use it in GitHub Desktop.
InfluxDB Cap and U metrics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Vm.where(:power_state => "on").each { |v| v.perf_capture("realtime") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM metrics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment