
* trying out api-extractor. * works with our setup of build. * wip. * changed the packages so it works better with the api-extractor. * Changes to make the api-extractor to work. * cleaned up the api-extractor config files. * added some more documentation. * added tsdoc-metadata to gitignore. * removed the generated docs (will do that in another PR). * added execute permission to script for generating dosc. * added so we will push generated docs to branch. * will clean packages_api on abort. * Fixed failing tests. * fixed formatting issue with typedoc comment. * temporarily disabled tslint rules about namespace until https://github.com/microsoft/rushstack/issues/1029 is resolved * temporary enabled bable namespaces. * updated build script. * updated script. * updated script with some colors. * changed to camelCase. * removed spacing. * Starting to add documentation guidelines. * added examples headline. * added menu options. * added parameters and return values. * Fixed merge error. * Added first version of auto-generated docs. * changed so we use the eslint ignore syntax. * changed to correct eslint ingnore comment. * fixed some spelling errors reported by codespell. * added script to generate docs in current folder. * updated api docs. * lerna bootstrap. * added eror to the ingore words list. * removed file that should be ignored. * updated locKFILE. * referenced the code comments guidelines. * updated packages. * updated deps. * updated the autogenerated dosc. * adding missing new line.
10 KiB
+++
-----------------------------------------------------------------------
Do not edit this file. It is automatically generated by API Documenter.
-----------------------------------------------------------------------
title = "DataSourceApi" keywords = ["grafana","documentation","sdk","@grafana/data"] type = "docs" draft = true +++
DataSourceApi class
The main data source abstraction interface, represents an instance of a data source
Although this is a class, datasource implementations do not *yet* need to extend it. As such, we can not yet add functions with default implementations.
Signature
export declare abstract class DataSourceApi<TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData>
Import
import { DataSourceApi } from '@grafana/data';
Constructors
Constructor | Modifiers | Description |
---|---|---|
constructor(instanceSettings) | Constructs a new instance of the DataSourceApi class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
components | DataSourcePluginComponents<DataSourceApi<TQuery, TOptions>, TQuery, TOptions> |
Set after constructor call, as the data source instance is the most common thing to pass around we attach the components to this instance for easy access | |
getLogRowContext | <TContextQueryOptions extends {}>(row: LogRowModel, options?: TContextQueryOptions) => Promise<DataQueryResponse> |
Retrieve context for a given log row | |
id | number |
Set in constructor | |
init | () => void |
Initializes a datasource after instantiation | |
interval | string |
min interval range | |
languageProvider | any |
Used in explore | |
meta | DataSourcePluginMeta |
static information about the datasource | |
name | string |
Set in constructor |
Methods
Method | Modifiers | Description |
---|---|---|
annotationQuery(options) | Can be optionally implemented to allow datasource to be a source of annotations for dashboard. To be visible in the annotation editor annotations capability also needs to be enabled in plugin.json. |
|
getHighlighterExpression(query) | Used in explore | |
getQueryDisplayText(query) | Convert a query to a simple text string | |
getQueryHints(query, results, rest) | Get hints for query improvements | |
getTagKeys(options) | Get tag keys for adhoc filters | |
getTagValues(options) | Get tag values for adhoc filters | |
getVersion(optionalOptions) | ||
importQueries(queries, originMeta) | Imports queries from a different datasource | |
interpolateVariablesInQueries(queries, scopedVars) | ||
metricFindQuery(query, options) | Variable query action. | |
modifyQuery(query, action) | Used in explore | |
query(request) | Query for data, and optionally stream results | |
targetContainsTemplate(query) | Used by alerting to check if query contains template variables | |
testDatasource() | Test & verify datasource settings & connection details |
constructor(instanceSettings)
Constructs a new instance of the DataSourceApi
class
Signature
constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);
Parameters
Parameter | Type | Description |
---|---|---|
instanceSettings | DataSourceInstanceSettings<TOptions> |
components property
Set after constructor call, as the data source instance is the most common thing to pass around we attach the components to this instance for easy access
Signature
components?: DataSourcePluginComponents<DataSourceApi<TQuery, TOptions>, TQuery, TOptions>;
getLogRowContext property
Retrieve context for a given log row
Signature
getLogRowContext?: <TContextQueryOptions extends {}>(row: LogRowModel, options?: TContextQueryOptions) => Promise<DataQueryResponse>;
id property
Set in constructor
Signature
readonly id: number;
init property
Initializes a datasource after instantiation
Signature
init?: () => void;
interval property
min interval range
Signature
interval?: string;
languageProvider property
Used in explore
Signature
languageProvider?: any;
meta property
static information about the datasource
Signature
meta?: DataSourcePluginMeta;
name property
Set in constructor
Signature
readonly name: string;
annotationQuery method
Can be optionally implemented to allow datasource to be a source of annotations for dashboard. To be visible in the annotation editor annotations
capability also needs to be enabled in plugin.json.
Signature
annotationQuery?(options: AnnotationQueryRequest<TQuery>): Promise<AnnotationEvent[]>;
Parameters
Parameter | Type | Description |
---|---|---|
options | AnnotationQueryRequest<TQuery> |
Returns:
Promise<AnnotationEvent[]>
getHighlighterExpression method
Used in explore
Signature
getHighlighterExpression?(query: TQuery): string[];
Parameters
Parameter | Type | Description |
---|---|---|
query | TQuery |
Returns:
string[]
getQueryDisplayText method
Convert a query to a simple text string
Signature
getQueryDisplayText?(query: TQuery): string;
Parameters
Parameter | Type | Description |
---|---|---|
query | TQuery |
Returns:
string
getQueryHints method
Get hints for query improvements
Signature
getQueryHints?(query: TQuery, results: any[], ...rest: any): QueryHint[];
Parameters
Parameter | Type | Description |
---|---|---|
query | TQuery |
|
results | any[] |
|
rest | any |
Returns:
QueryHint[]
getTagKeys method
Get tag keys for adhoc filters
Signature
getTagKeys?(options?: any): Promise<MetricFindValue[]>;
Parameters
Parameter | Type | Description |
---|---|---|
options | any |
Returns:
Promise<MetricFindValue[]>
getTagValues method
Get tag values for adhoc filters
Signature
getTagValues?(options: any): Promise<MetricFindValue[]>;
Parameters
Parameter | Type | Description |
---|---|---|
options | any |
Returns:
Promise<MetricFindValue[]>
getVersion method
Signature
getVersion?(optionalOptions?: any): Promise<string>;
Parameters
Parameter | Type | Description |
---|---|---|
optionalOptions | any |
Returns:
Promise<string>
importQueries method
Imports queries from a different datasource
Signature
importQueries?(queries: TQuery[], originMeta: PluginMeta): Promise<TQuery[]>;
Parameters
Parameter | Type | Description |
---|---|---|
queries | TQuery[] |
|
originMeta | PluginMeta |
Returns:
Promise<TQuery[]>
interpolateVariablesInQueries method
Signature
interpolateVariablesInQueries?(queries: TQuery[], scopedVars: ScopedVars | {}): TQuery[];
Parameters
Parameter | Type | Description |
---|---|---|
queries | TQuery[] |
|
scopedVars | ScopedVars | {} |
Returns:
TQuery[]
metricFindQuery method
Variable query action.
Signature
metricFindQuery?(query: any, options?: any): Promise<MetricFindValue[]>;
Parameters
Parameter | Type | Description |
---|---|---|
query | any |
|
options | any |
Returns:
Promise<MetricFindValue[]>
modifyQuery method
Used in explore
Signature
modifyQuery?(query: TQuery, action: QueryFixAction): TQuery;
Parameters
Parameter | Type | Description |
---|---|---|
query | TQuery |
|
action | QueryFixAction |
Returns:
TQuery
query method
Query for data, and optionally stream results
Signature
abstract query(request: DataQueryRequest<TQuery>): Promise<DataQueryResponse> | Observable<DataQueryResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
request | DataQueryRequest<TQuery> |
Returns:
Promise<DataQueryResponse> | Observable<DataQueryResponse>
targetContainsTemplate method
Used by alerting to check if query contains template variables
Signature
targetContainsTemplate?(query: TQuery): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
query | TQuery |
Returns:
boolean
testDatasource method
Test & verify datasource settings & connection details
Signature
abstract testDatasource(): Promise<any>;
Returns:
Promise<any>