class Grafana::GrafanaPropertyDatasource

Implements the datasource interface to grafana model properties.

Public Instance Methods

default_variable_format() click to toggle source

@see AbstractDatasource#default_variable_format

# File lib/grafana/grafana_property_datasource.rb, line 28
def default_variable_format
  'glob'
end
name() click to toggle source

@see AbstractDatasource#name

# File lib/grafana/grafana_property_datasource.rb, line 33
def name
  self.class.to_s
end
request(query_description) click to toggle source

:raw_query needs to contain a Hash with the following structure:

{
  property_name: Name of the queried property as String
  panel:         {Panel} object to query
}

@see AbstractDatasource#request

# File lib/grafana/grafana_property_datasource.rb, line 13
def request(query_description)
  raise MissingSqlQueryError if query_description[:raw_query].nil?

  panel = query_description[:raw_query][:panel]
  property_name = query_description[:raw_query][:property_name]

  return "Panel property '#{property_name}' does not exist for panel '#{panel.id}'" unless panel.field(property_name)

  {
    header: [query_description[:raw_query][:property_name]],
    content: [replace_variables(panel.field(property_name), query_description[:variables])]
  }
end