Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Enterprise Open source

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

typescript
export interface DataSourceSrv 

Import

typescript
import { DataSourceSrv } from '@grafana/runtime';

Methods

MethodDescription
get(ref, scopedVars)Returns the requested dataSource. If it cannot be found it rejects the promise.
getInstanceSettings(ref, scopedVars)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

typescript
get(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>;

Parameters

ParameterTypeDescription
refDataSourceRef | string | nullThe datasource identifier, typically an object with UID and type,
scopedVarsScopedVarsvariables used to interpolate a templated passed as name.

Returns:

Promise<DataSourceApi>

getInstanceSettings method

Get settings and plugin metadata by name or uid

Signature

typescript
getInstanceSettings(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): DataSourceInstanceSettings | undefined;

Parameters

ParameterTypeDescription
refDataSourceRef | string | null
scopedVarsScopedVars

Returns:

DataSourceInstanceSettings | undefined

getList method

Get a list of data sources

Signature

typescript
getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[];

Parameters

ParameterTypeDescription
filtersGetDataSourceListFilters

Returns:

DataSourceInstanceSettings[]