DataSourceSrv interface

This is the entry point for communicating with a datasource that is added as a plugin (both external and internal). Via this service you will get access to the DataSourceApi that have a rich API for communicating with the datasource.

Signature

  1. export interface DataSourceSrv

Import

  1. import { DataSourceSrv } from '@grafana/runtime';

Methods

MethodDescription
get(nameOrUid, scopedVars)Returns the requested dataSource. If it cannot be found it rejects the promise.
getInstanceSettings(nameOrUid)Get settings and plugin metadata by name or uid
getList(filters)Get a list of data sources

get method

Returns the requested dataSource. If it cannot be found it rejects the promise.

Signature

  1. get(nameOrUid?: string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>;

Parameters

ParameterTypeDescription
nameOrUidstring | nullname or Uid of the datasource plugin you want to use.
scopedVarsScopedVarsvariables used to interpolate a templated passed as name.

Returns:

Promise<DataSourceApi>

getInstanceSettings method

Get settings and plugin metadata by name or uid

Signature

  1. getInstanceSettings(nameOrUid: string | null | undefined): DataSourceInstanceSettings | undefined;

Parameters

ParameterTypeDescription
nameOrUidstring | null | undefined

Returns:

DataSourceInstanceSettings | undefined

getList method

Get a list of data sources

Signature

  1. getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[];

Parameters

ParameterTypeDescription
filtersGetDataSourceListFilters

Returns:

DataSourceInstanceSettings[]