Datasource: Add optional `queries` parameter to `getTagKeysOptions` (#81071)

add optional queries parameter to getTagKeysOptions
pull/81372/head
Ashley Harrison 1 year ago committed by GitHub
parent 5a2e9ea2ee
commit 1a6105be8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      packages/grafana-data/src/types/datasource.ts
  2. 2
      public/app/plugins/datasource/influxdb/datasource.ts
  3. 2
      public/app/plugins/datasource/loki/datasource.ts
  4. 2
      public/app/plugins/datasource/prometheus/datasource.ts

@ -287,7 +287,7 @@ abstract class DataSourceApi<
/**
* Get tag keys for adhoc filters
*/
getTagKeys?(options?: DataSourceGetTagKeysOptions): Promise<MetricFindValue[]>;
getTagKeys?(options?: DataSourceGetTagKeysOptions<TQuery>): Promise<MetricFindValue[]>;
/**
* Get tag values for adhoc filters
@ -367,7 +367,7 @@ abstract class DataSourceApi<
/**
* Options argument to DataSourceAPI.getTagKeys
*/
export interface DataSourceGetTagKeysOptions {
export interface DataSourceGetTagKeysOptions<TQuery extends DataQuery = DataQuery> {
/**
* The other existing filters or base filters. New in v10.3
*/
@ -376,6 +376,7 @@ export interface DataSourceGetTagKeysOptions {
* Context time range. New in v10.3
*/
timeRange?: TimeRange;
queries?: TQuery[];
}
/**

@ -339,7 +339,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
// By implementing getTagKeys and getTagValues we add ad-hoc filters functionality
// Used in public/app/features/variables/adhoc/picker/AdHocFilterKey.tsx::fetchFilterKeys
getTagKeys(options?: DataSourceGetTagKeysOptions) {
getTagKeys(options?: DataSourceGetTagKeysOptions<InfluxQuery>) {
const query = buildMetadataQuery({
type: 'TAG_KEYS',
templateService: this.templateSrv,

@ -753,7 +753,7 @@ export class LokiDatasource
* Implemented as part of the DataSourceAPI. Retrieves tag keys that can be used for ad-hoc filtering.
* @returns A Promise that resolves to an array of label names represented as MetricFindValue objects.
*/
async getTagKeys(options?: DataSourceGetTagKeysOptions): Promise<MetricFindValue[]> {
async getTagKeys(options?: DataSourceGetTagKeysOptions<LokiQuery>): Promise<MetricFindValue[]> {
const result = await this.languageProvider.fetchLabels({ timeRange: options?.timeRange });
return result.map((value: string) => ({ text: value }));
}

@ -668,7 +668,7 @@ export class PrometheusDatasource
// this is used to get label keys, a.k.a label names
// it is used in metric_find_query.ts
// and in Tempo here grafana/public/app/plugins/datasource/tempo/QueryEditor/ServiceGraphSection.tsx
async getTagKeys(options: DataSourceGetTagKeysOptions): Promise<MetricFindValue[]> {
async getTagKeys(options: DataSourceGetTagKeysOptions<PromQuery>): Promise<MetricFindValue[]> {
if (!options || options.filters.length === 0) {
await this.languageProvider.fetchLabels(options.timeRange);
return this.languageProvider.getLabelKeys().map((k) => ({ value: k, text: k }));

Loading…
Cancel
Save