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(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
reload()Reloads the DataSourceSrv

get method

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

Signature

  1. 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

  1. 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

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

Parameters

ParameterTypeDescription
filtersGetDataSourceListFilters

Returns:

DataSourceInstanceSettings[]

reload method

Reloads the DataSourceSrv

Signature

  1. reload(): void;

Returns:

void