Class: Grafana::GrafanaEnvironmentDatasource

Inherits:
AbstractDatasource show all
Defined in:
lib/grafana/grafana_environment_datasource.rb

Overview

Implements a datasource to return environment related information about the grafana instance in a tabular format.

Instance Attribute Summary

Attributes inherited from AbstractDatasource

#model

Instance Method Summary collapse

Methods inherited from AbstractDatasource

build_instance, #category, handles?, #id, inherited, #initialize, #raw_query_from_panel_model, #replace_variables, #type, #uid

Constructor Details

This class inherits a constructor from Grafana::AbstractDatasource

Instance Method Details

#default_variable_formatObject



23
24
25
# File 'lib/grafana/grafana_environment_datasource.rb', line 23

def default_variable_format
  nil
end

#nameObject



28
29
30
# File 'lib/grafana/grafana_environment_datasource.rb', line 28

def name
  self.class.to_s
end

#request(query_description) ⇒ Object

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

{
  grafana:  {Grafana} object to query
  mode:     'general' (default) or 'dashboards' for receiving different environment information
}


13
14
15
16
17
18
19
20
# File 'lib/grafana/grafana_environment_datasource.rb', line 13

def request(query_description)
  raise MissingSqlQueryError if query_description[:raw_query].nil?
  raw_query = {mode: 'general'}.merge(query_description[:raw_query])

  return dashboards_data(raw_query[:grafana]) if raw_query[:mode] == 'dashboards'

  general_data(raw_query[:grafana])
end