Method: Grafana::Grafana#datasource_by_name

Defined in:
lib/grafana/grafana.rb

#datasource_by_name(datasource_name) ⇒ Datasource

Returns the datasource, which has been queried by the datasource name.

Parameters:

  • datasource_name (String)

    name of the searched datasource

Returns:

  • (Datasource)

    Datasource for the specified datasource name

Raises:



102
103
104
105
106
107
108
109
# File 'lib/grafana/grafana.rb', line 102

def datasource_by_name(datasource_name)
  datasource_name = 'default' if datasource_name.to_s.empty?
  # TODO: PRIO add support for grafana builtin datasource types
  return UnsupportedDatasource.new(nil) if datasource_name.to_s =~ /-- (?:Mixed|Dashboard|Grafana) --/
  raise DatasourceDoesNotExistError.new('name', datasource_name) unless @datasources[datasource_name]

  @datasources[datasource_name]
end