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

    Import

    Constructors

    Properties

    PropertyModifiersTypeDescription
    annotationsAnnotationSupport<TQuery>An annotation processor allows explicit control for how annotations are managed.It is only necessary to configure an annotation processor if the default behavior is not desirable
    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>
    numberSet in constructor
    init() => voidInitializes a datasource after instantiation
    stringmin interval range
    languageProvideranyUsed in explore
    DataSourcePluginMetastatic information about the datasource
    namestringSet in constructor
    stringSet in constructor
    uidstringSet in constructor

    Methods

    MethodModifiersDescription
    Can be optionally implemented to allow datasource to be a source of annotations for dashboard. This function will only be called if an angular is configured and the is undefined
    filterQuery(query)Override to skip executing a query
    getImportQueryConfiguration()Returns configuration for importing queries from other data sources
    Convert a query to a simple text string
    getQueryHints(query, results, rest)Get hints for query improvements
    Get an identifier object for this datasource instance
    getTagKeys(options)Get tag keys for adhoc filters
    Get tag values for adhoc filters
    getVersion(optionalOptions)
    Imports queries from a different datasource
    interpolateVariablesInQueries(queries, scopedVars)
    Variable query action.
    modifyQuery(query, action)Used in explore
    Query for data, and optionally stream results
    showContextToggle(row)
    Used by alerting to check if query contains template variables
    testDatasource()Test & verify datasource settings & connection details (returning TestingStatus)When verification fails - errors specific to the data source should be handled here and converted to a TestingStatus object. Unknown errors and HTTP errors can be re-thrown and will be handled here: public/app/features/datasources/state/actions.ts

    Constructs a new instance of the DataSourceApi class

    Signature

    1. constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);

    Parameters

    ParameterTypeDescription
    instanceSettingsDataSourceInstanceSettings<TOptions>

    annotations property

    An annotation processor allows explicit control for how annotations are managed.

    It is only necessary to configure an annotation processor if the default behavior is not desirable

    Signature

    1. annotations?: AnnotationSupport<TQuery>;

    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

    1. components?: DataSourcePluginComponents<DataSourceApi<TQuery, TOptions>, TQuery, TOptions>;

    getLogRowContext property

    Signature

    1. getLogRowContext?: <TContextQueryOptions extends {}>(row: LogRowModel, options?: TContextQueryOptions) => Promise<DataQueryResponse>;

    id property

    Set in constructor

    Signature

    1. readonly id: number;

    init property

    Initializes a datasource after instantiation

    Signature

    1. init?: () => void;

    interval property

    min interval range

    Signature

    1. interval?: string;

    languageProvider property

    Used in explore

    Signature

    1. languageProvider?: any;

    meta property

    static information about the datasource

    Signature

    name property

    Set in constructor

    Signature

      Set in constructor

      Signature

      1. readonly type: string;

      uid property

      Set in constructor

      Signature

      1. readonly uid: string;

      annotationQuery method

      Can be optionally implemented to allow datasource to be a source of annotations for dashboard. This function will only be called if an angular is configured and the is undefined

      Signature

      1. annotationQuery?(options: AnnotationQueryRequest<TQuery>): Promise<AnnotationEvent[]>;

      Parameters

      ParameterTypeDescription
      options

      Returns:

      Promise<AnnotationEvent[]>

      filterQuery method

      Override to skip executing a query

      Signature

      1. /** @virtual */
      2. filterQuery?(query: TQuery): boolean;
      ParameterTypeDescription
      queryTQuery

      Returns:

      boolean

      false if the query should be skipped

      getHighlighterExpression method

      Signature

      1. getHighlighterExpression?(query: TQuery): string[];

      Parameters

      Returns:

      string[]

      getImportQueryConfiguration method

      Returns configuration for importing queries from other data sources

      Signature

      1. getImportQueryConfiguration?(): TQueryImportConfiguration;

      Returns:

      TQueryImportConfiguration

      getQueryDisplayText method

      Convert a query to a simple text string

      Signature

      1. getQueryDisplayText?(query: TQuery): string;

      Parameters

      ParameterTypeDescription
      queryTQuery

      Returns:

      string

      getQueryHints method

      Get hints for query improvements

      Signature

      1. getQueryHints?(query: TQuery, results: any[], ...rest: any): QueryHint[];

      Parameters

      ParameterTypeDescription
      queryTQuery
      resultsany[]
      restany

      Returns:

      QueryHint[]

      getRef method

      Get an identifier object for this datasource instance

      Signature

      Returns:

      DataSourceRef

      getTagKeys method

      Get tag keys for adhoc filters

      Signature

      1. getTagKeys?(options?: any): Promise<MetricFindValue[]>;

      Parameters

      ParameterTypeDescription
      optionsany

      Returns:

      Promise<MetricFindValue[]>

      Get tag values for adhoc filters

      Signature

      1. getTagValues?(options: any): Promise<MetricFindValue[]>;

      Parameters

      ParameterTypeDescription
      optionsany

      Returns:

      Promise<MetricFindValue[]>

      getVersion method

      Signature

      1. getVersion?(optionalOptions?: any): Promise<string>;

      Parameters

      ParameterTypeDescription
      optionalOptions

      Returns:

      importQueries method

      Imports queries from a different datasource

      Signature

      1. importQueries?(queries: DataQuery[], originDataSource: DataSourceApi<DataQuery>): Promise<TQuery[]>;

      Parameters

      Returns:

      Promise<TQuery[]>

      interpolateVariablesInQueries method

      Signature

      1. interpolateVariablesInQueries?(queries: TQuery[], scopedVars: ScopedVars | {}): TQuery[];

      Parameters

      ParameterTypeDescription
      queriesTQuery[]
      scopedVarsScopedVars | {}

      Returns:

      TQuery[]

      metricFindQuery method

      Variable query action.

      Signature

      1. metricFindQuery?(query: any, options?: any): Promise<MetricFindValue[]>;

      Parameters

      ParameterTypeDescription
      queryany
      optionsany

      Returns:

      Promise<MetricFindValue[]>

      modifyQuery method

      Used in explore

      Signature

      1. modifyQuery?(query: TQuery, action: QueryFixAction): TQuery;

      Parameters

      ParameterTypeDescription
      queryTQuery
      actionQueryFixAction

      Returns:

      TQuery

      query method

      Query for data, and optionally stream results

      Signature

      1. abstract query(request: DataQueryRequest<TQuery>): Promise<DataQueryResponse> | Observable<DataQueryResponse>;

      Parameters

      ParameterTypeDescription
      requestDataQueryRequest<TQuery>

      Returns:

      Promise<DataQueryResponse> | Observable<DataQueryResponse>

      showContextToggle method

      Signature

      1. showContextToggle?(row?: LogRowModel): boolean;

      Parameters

      ParameterTypeDescription
      rowLogRowModel

      Returns:

      boolean

      targetContainsTemplate method

      Used by alerting to check if query contains template variables

      Signature

      Parameters

      Returns:

      boolean

      testDatasource method

      Test & verify datasource settings & connection details (returning TestingStatus)

      When verification fails - errors specific to the data source should be handled here and converted to a TestingStatus object. Unknown errors and HTTP errors can be re-thrown and will be handled here: public/app/features/datasources/state/actions.ts

      Signature

      1. abstract testDatasource(): Promise<any>;

      Returns: