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
export interface DataSourceSrv
Import
import { DataSourceSrv } from '@grafana/runtime';
Methods
Method | Description |
---|---|
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
get(nameOrUid?: string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>;
Parameters
Parameter | Type | Description |
---|---|---|
nameOrUid | string | null | name or Uid of the datasource plugin you want to use. |
scopedVars | ScopedVars | variables used to interpolate a templated passed as name. |
Returns:
Promise<DataSourceApi>
getInstanceSettings method
Get settings and plugin metadata by name or uid
Signature
getInstanceSettings(nameOrUid: string | null | undefined): DataSourceInstanceSettings | undefined;
Parameters
Parameter | Type | Description |
---|---|---|
nameOrUid | string | null | undefined |
Returns:
DataSourceInstanceSettings | undefined
getList method
Get a list of data sources
Signature
getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[];
Parameters
Parameter | Type | Description |
---|---|---|
filters | GetDataSourceListFilters |
Returns:
DataSourceInstanceSettings[]