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
Method | Description |
---|---|
get(name, scopedVars) | |
getInstanceSettings(nameOrUid) | Get settings and plugin metadata by name or uid |
getList(filters) | Get a list of data sources |
get method
Signature
typescript
get(name?: string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>;
Parameters
Parameter | Type | Description |
---|---|---|
name | string | null | name 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
typescript
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
typescript
getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[];
Parameters
Parameter | Type | Description |
---|---|---|
filters | GetDataSourceListFilters |
Returns:
DataSourceInstanceSettings[]
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Getting started with the Grafana LGTM Stack
In this webinar, we’ll demo how to get started using the LGTM Stack: Loki for logs, Grafana for visualization, Tempo for traces, and Mimir for metrics.
Video
Getting started with Grafana dashboard design
In this webinar, you'll learn how to design stylish and easily accessible Grafana dashboards that tell a story.
Video
Building advanced Grafana dashboards
In this webinar, we’ll demo how to build and format Grafana dashboards.