Documentation Index
Fetch the curated documentation index at: https://archive.grafana.com/llms.txt
Fetch the complete documentation index at: https://archive.grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: /docs/grafana/v9.0/packages_api/runtime/datasourcesrv.md (append .md) or send Accept: text/markdown to /docs/grafana/v9.0/packages_api/runtime/datasourcesrv/. For the curated documentation index, use https://archive.grafana.com/llms.txt. For the complete documentation index, use https://archive.grafana.com/llms-full.txt.
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.
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(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
get(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>;Parameters
| Parameter | Type | Description |
|---|---|---|
| ref | DataSourceRef | string | null | The datasource identifier, typically an object with UID and type, |
| 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(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): DataSourceInstanceSettings | undefined;Parameters
| Parameter | Type | Description |
|---|---|---|
| ref | DataSourceRef | string | null | |
| scopedVars | ScopedVars |
Returns:
DataSourceInstanceSettings | undefined
getList method
Get a list of data sources
Signature
getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[];Parameters
| Parameter | Type | Description |
|---|---|---|
| filters | GetDataSourceListFilters |
Returns:
DataSourceInstanceSettings[]
reload method
Reloads the DataSourceSrv
Signature
reload(): void;Returns:
void