mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datasource: Add optional queries parameter to getTagKeysOptions (#81071)
add optional queries parameter to getTagKeysOptions
This commit is contained in:
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user