+++ # ----------------------------------------------------------------------- # Do not edit this file. It is automatically generated by API Documenter. # ----------------------------------------------------------------------- title = "DataSourceWithBackend" keywords = ["grafana","documentation","sdk","@grafana/runtime"] type = "docs" +++ ## DataSourceWithBackend class Extend this class to implement a data source plugin that is depending on the Grafana backend API. Signature ```typescript export declare class DataSourceWithBackend extends DataSourceApi ``` Import ```typescript import { DataSourceWithBackend } from '@grafana/runtime'; ``` Constructors | Constructor | Modifiers | Description | | --- | --- | --- | | [constructor(instanceSettings)](#constructor-instancesettings) | | Constructs a new instance of the DataSourceWithBackend class | Methods | Method | Modifiers | Description | | --- | --- | --- | | [applyTemplateVariables(query, scopedVars)](#applytemplatevariables-method) | | Override to apply template variables. The result is usually also TQuery, but sometimes this can be used to modify the query structure before sending to the backend.NOTE: if you do modify the structure or use template variables, alerting queries may not work as expected | | [callHealthCheck()](#callhealthcheck-method) | | Run the datasource healthcheck | | [filterQuery(query)](#filterquery-method) | | Override to skip executing a query | | [getResource(path, params)](#getresource-method) | | Make a GET request to the datasource resource path | | [postResource(path, body)](#postresource-method) | | Send a POST request to the datasource resource path | | [processResponse(res)](#processresponse-method) | | Optionally augment the response before returning the results to the | | [query(request)](#query-method) | | Ideally final -- any other implementation may not work as expected | | [testDatasource()](#testdatasource-method) | | Checks the plugin health | ### constructor(instanceSettings) Constructs a new instance of the `DataSourceWithBackend` class Signature ```typescript constructor(instanceSettings: DataSourceInstanceSettings); ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | instanceSettings | DataSourceInstanceSettings<TOptions> | | ### applyTemplateVariables method Override to apply template variables. The result is usually also `TQuery`, but sometimes this can be used to modify the query structure before sending to the backend. NOTE: if you do modify the structure or use template variables, alerting queries may not work as expected Signature ```typescript /** @virtual */ applyTemplateVariables(query: TQuery, scopedVars: ScopedVars): Record; ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | query | TQuery | | | scopedVars | ScopedVars | | Returns: `Record` ### callHealthCheck method Run the datasource healthcheck Signature ```typescript callHealthCheck(): Promise; ``` Returns: `Promise` ### filterQuery method Override to skip executing a query Signature ```typescript /** @virtual */ filterQuery?(query: TQuery): boolean; ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | query | TQuery | | Returns: `boolean` ### getResource method Make a GET request to the datasource resource path Signature ```typescript getResource(path: string, params?: any): Promise; ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | path | string | | | params | any | | Returns: `Promise` ### postResource method Send a POST request to the datasource resource path Signature ```typescript postResource(path: string, body?: any): Promise; ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | path | string | | | body | any | | Returns: `Promise` ### processResponse method Optionally augment the response before returning the results to the Signature ```typescript processResponse?(res: DataQueryResponse): Promise; ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | res | DataQueryResponse | | Returns: `Promise` ### query method Ideally final -- any other implementation may not work as expected Signature ```typescript query(request: DataQueryRequest): Observable; ``` Parameters | Parameter | Type | Description | | --- | --- | --- | | request | DataQueryRequest<TQuery> | | Returns: `Observable` ### testDatasource method Checks the plugin health Signature ```typescript testDatasource(): Promise; ``` Returns: `Promise`