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.
DataSourceWithBackend class
Extend this class to implement a data source plugin that is depending on the Grafana backend API.
Signature
export declare class DataSourceWithBackend<TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData> extends DataSourceApi<TQuery, TOptions>
Import
import { DataSourceWithBackend } from '@grafana/runtime';
Constructors
Constructor | Modifiers | Description |
---|---|---|
constructor(instanceSettings) | Constructs a new instance of the DataSourceWithBackend class |
Methods
Method | Modifiers | Description |
---|---|---|
applyTemplateVariables(query) | Override to apply template variables | |
callHealthCheck() | Run the datasource healthcheck | |
getResource(path, params) | Make a GET request to the datasource resource path | |
postResource(path, body) | Send a POST request to the datasource resource path | |
query(request) | Ideally final – any other implementation may not work as expected | |
testDatasource() | Checks the plugin health |
constructor(instanceSettings)
Constructs a new instance of the DataSourceWithBackend
class
Signature
constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);
Parameters
Parameter | Type | Description |
---|---|---|
instanceSettings | DataSourceInstanceSettings<TOptions> |
applyTemplateVariables method
Override to apply template variables
Signature
/** @virtual */
applyTemplateVariables(query: DataQuery): DataQuery;
Parameters
Parameter | Type | Description |
---|---|---|
query | DataQuery |
Returns:
DataQuery
callHealthCheck method
Run the datasource healthcheck
Signature
callHealthCheck(): Promise<HealthCheckResult>;
Returns:
Promise<HealthCheckResult>
getResource method
Make a GET request to the datasource resource path
Signature
getResource(path: string, params?: any): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
path | string | |
params | any |
Returns:
Promise<any>
postResource method
Send a POST request to the datasource resource path
Signature
postResource(path: string, body?: any): Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
path | string | |
body | any |
Returns:
Promise<any>
query method
Ideally final – any other implementation may not work as expected
Signature
query(request: DataQueryRequest): Observable<DataQueryResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
request | DataQueryRequest |
Returns:
Observable<DataQueryResponse>
testDatasource method
Checks the plugin health
Signature
testDatasource(): Promise<any>;
Returns:
Promise<any>