Skip to content

Commit

Permalink
Merge pull request #14857 from zakiva/fix_realtime_heatmaps
Browse files Browse the repository at this point in the history
Fix Containers dashboard heatmaps
  • Loading branch information
kbrock authored May 31, 2017
2 parents e871897 + 12ad5b5 commit 5d0ec5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/metric/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,12 @@ def self.get_time_interval(obj, timestamp)

start_time..timestamp
end

def self.latest_metrics(resource_type, since_timestamp, resource_ids = nil)
metrics = Metric.where(:resource_type => resource_type)
metrics = metrics.where(:resource_id => resource_ids) if resource_ids
metrics = metrics.order(:resource_id, :timestamp => :desc)
metrics = metrics.where('timestamp > ?', since_timestamp)
metrics.select('DISTINCT ON (metrics.resource_id) metrics.*')
end
end
5 changes: 5 additions & 0 deletions spec/factories/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
capture_interval_name "realtime"
resource_type "Host"
end

factory :metric_container_node_rt, :parent => :metric, :class => :Metric do
capture_interval_name "realtime"
resource_type "ContainerNode"
end
end

0 comments on commit 5d0ec5b

Please sign in to comment.