The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/docs/sources/packages_api/runtime/datasourcewithbackend.md

180 lines
4.3 KiB

+++
# -----------------------------------------------------------------------
# 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.
<b>Signature</b>
```typescript
export declare class DataSourceWithBackend<TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData> extends DataSourceApi<TQuery, TOptions>
```
<b>Import</b>
```typescript
import { DataSourceWithBackend } from '@grafana/runtime';
```
<b>Constructors</b>
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [constructor(instanceSettings)](#constructor-instancesettings) | | Constructs a new instance of the <code>DataSourceWithBackend</code> class |
<b>Methods</b>
| Method | Modifiers | Description |
| --- | --- | --- |
| [applyTemplateVariables(query)](#applytemplatevariables-method) | | Override to apply template variables |
| [callHealthCheck()](#callhealthcheck-method) | | Run the datasource healthcheck |
| [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 |
| [query(request)](#query-method) | | Ideally final -- any other implementation may not work as expected |
| [testDatasource()](#testdatasource-method) | | Checks the plugin health |
| [toDataQueryResponse(rsp)](#todataqueryresponse-method) | | This makes the arrow library loading async. |
### constructor(instanceSettings)
Constructs a new instance of the `DataSourceWithBackend` class
<b>Signature</b>
```typescript
constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);
```
<b>Parameters</b>
| Parameter | Type | Description |
| --- | --- | --- |
| instanceSettings | <code>DataSourceInstanceSettings&lt;TOptions&gt;</code> | |
### applyTemplateVariables method
Override to apply template variables
<b>Signature</b>
```typescript
/** @virtual */
applyTemplateVariables(query: DataQuery): DataQuery;
```
<b>Parameters</b>
| Parameter | Type | Description |
| --- | --- | --- |
| query | <code>DataQuery</code> | |
<b>Returns:</b>
`DataQuery`
### callHealthCheck method
Run the datasource healthcheck
<b>Signature</b>
```typescript
callHealthCheck(): Promise<HealthCheckResult>;
```
<b>Returns:</b>
`Promise<HealthCheckResult>`
### getResource method
Make a GET request to the datasource resource path
<b>Signature</b>
```typescript
getResource(path: string, params?: any): Promise<any>;
```
<b>Parameters</b>
| Parameter | Type | Description |
| --- | --- | --- |
| path | <code>string</code> | |
| params | <code>any</code> | |
<b>Returns:</b>
`Promise<any>`
### postResource method
Send a POST request to the datasource resource path
<b>Signature</b>
```typescript
postResource(path: string, body?: any): Promise<any>;
```
<b>Parameters</b>
| Parameter | Type | Description |
| --- | --- | --- |
| path | <code>string</code> | |
| body | <code>any</code> | |
<b>Returns:</b>
`Promise<any>`
### query method
Ideally final -- any other implementation may not work as expected
<b>Signature</b>
```typescript
query(request: DataQueryRequest): Observable<DataQueryResponse>;
```
<b>Parameters</b>
| Parameter | Type | Description |
| --- | --- | --- |
| request | <code>DataQueryRequest</code> | |
<b>Returns:</b>
`Observable<DataQueryResponse>`
### testDatasource method
Checks the plugin health
<b>Signature</b>
```typescript
testDatasource(): Promise<any>;
```
<b>Returns:</b>
`Promise<any>`
### toDataQueryResponse method
This makes the arrow library loading async.
<b>Signature</b>
```typescript
toDataQueryResponse(rsp: any): Promise<DataQueryResponse>;
```
<b>Parameters</b>
| Parameter | Type | Description |
| --- | --- | --- |
| rsp | <code>any</code> | |
<b>Returns:</b>
`Promise<DataQueryResponse>`