class Grafana::Panel
Representation of one specific panel in a {Dashboard} instance.
Attributes
dashboard[R]
@return [Dashboard] parent {Dashboard} object
model[R]
Public Class Methods
new(model, dashboard)
click to toggle source
@param model [Hash] converted JSON Hash of the panel @param dashboard [Dashboard] parent {Dashboard} object
# File lib/grafana/panel.rb, line 12 def initialize(model, dashboard) @model = model @dashboard = dashboard end
Public Instance Methods
datasource()
click to toggle source
@return [Datasource] datasource object specified for the current panel
# File lib/grafana/panel.rb, line 30 def datasource dashboard.grafana.datasource_by_name(@model['datasource']) end
field(field)
click to toggle source
@return [String] content of the requested field or +''+ if not found
# File lib/grafana/panel.rb, line 18 def field(field) return @model[field] if @model.key?(field) nil end
id()
click to toggle source
@return [String] panel ID
# File lib/grafana/panel.rb, line 25 def id @model['id'] end
query(query_letter)
click to toggle source
@return [String] query string for the requested query letter
# File lib/grafana/panel.rb, line 35 def query(query_letter) query_item = @model['targets'].select { |item| item['refId'].to_s == query_letter.to_s }.first raise QueryLetterDoesNotExistError.new(query_letter, self) unless query_item datasource.raw_query_from_panel_model(query_item) end
render_url()
click to toggle source
@return [String] relative rendering URL for the panel, to create an image out of it
# File lib/grafana/panel.rb, line 43 def render_url "/render/d-solo/#{@dashboard.id}?panelId=#{@model['id']}" end