mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add optional queries parameter to DataSourceGetTagValuesOptions (#85436)
Add optional `queries` parameter to `getTagKeysOptions`
This commit is contained in:
@@ -290,7 +290,7 @@ abstract class DataSourceApi<
|
||||
/**
|
||||
* Get tag values for adhoc filters
|
||||
*/
|
||||
getTagValues?(options: DataSourceGetTagValuesOptions): Promise<MetricFindValue[]>;
|
||||
getTagValues?(options: DataSourceGetTagValuesOptions<TQuery>): Promise<MetricFindValue[]>;
|
||||
|
||||
/**
|
||||
* Set after constructor call, as the data source instance is the most common thing to pass around
|
||||
@@ -380,7 +380,7 @@ export interface DataSourceGetTagKeysOptions<TQuery extends DataQuery = DataQuer
|
||||
/**
|
||||
* Options argument to DataSourceAPI.getTagValues
|
||||
*/
|
||||
export interface DataSourceGetTagValuesOptions {
|
||||
export interface DataSourceGetTagValuesOptions<TQuery extends DataQuery = DataQuery> {
|
||||
key: string;
|
||||
/**
|
||||
* The other existing filters or base filters. New in v10.3
|
||||
@@ -390,6 +390,7 @@ export interface DataSourceGetTagValuesOptions {
|
||||
* Context time range. New in v10.3
|
||||
*/
|
||||
timeRange?: TimeRange;
|
||||
queries?: TQuery[];
|
||||
}
|
||||
|
||||
export interface MetadataInspectorProps<
|
||||
|
||||
@@ -696,7 +696,7 @@ export class PrometheusDatasource
|
||||
}
|
||||
|
||||
// By implementing getTagKeys and getTagValues we add ad-hoc filters functionality
|
||||
async getTagValues(options: DataSourceGetTagValuesOptions) {
|
||||
async getTagValues(options: DataSourceGetTagValuesOptions<PromQuery>) {
|
||||
const labelFilters: QueryBuilderLabelFilter[] = options.filters.map((f) => ({
|
||||
label: f.key,
|
||||
value: f.value,
|
||||
|
||||
@@ -855,7 +855,7 @@ export class ElasticDatasource
|
||||
return lastValueFrom(this.getFields());
|
||||
}
|
||||
|
||||
getTagValues(options: DataSourceGetTagValuesOptions) {
|
||||
getTagValues(options: DataSourceGetTagValuesOptions<ElasticsearchQuery>) {
|
||||
return lastValueFrom(this.getTerms({ field: options.key }, options.timeRange));
|
||||
}
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
return this.metricFindQuery(query);
|
||||
}
|
||||
|
||||
getTagValues(options: DataSourceGetTagValuesOptions) {
|
||||
getTagValues(options: DataSourceGetTagValuesOptions<InfluxQuery>) {
|
||||
const query = buildMetadataQuery({
|
||||
type: 'TAG_VALUES',
|
||||
templateService: this.templateSrv,
|
||||
|
||||
@@ -755,7 +755,7 @@ export class LokiDatasource
|
||||
* Implemented as part of the DataSourceAPI. Retrieves tag values that can be used for ad-hoc filtering.
|
||||
* @returns A Promise that resolves to an array of label values represented as MetricFindValue objects
|
||||
*/
|
||||
async getTagValues(options: DataSourceGetTagValuesOptions): Promise<MetricFindValue[]> {
|
||||
async getTagValues(options: DataSourceGetTagValuesOptions<LokiQuery>): Promise<MetricFindValue[]> {
|
||||
const result = await this.languageProvider.fetchLabelValues(options.key, { timeRange: options.timeRange });
|
||||
return result.map((value: string) => ({ text: value }));
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ export class PrometheusDatasource
|
||||
}
|
||||
|
||||
// By implementing getTagKeys and getTagValues we add ad-hoc filters functionality
|
||||
async getTagValues(options: DataSourceGetTagValuesOptions) {
|
||||
async getTagValues(options: DataSourceGetTagValuesOptions<PromQuery>) {
|
||||
const labelFilters: QueryBuilderLabelFilter[] = options.filters.map((f) => ({
|
||||
label: f.key,
|
||||
value: f.value,
|
||||
|
||||
@@ -216,7 +216,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
||||
}
|
||||
|
||||
// Allows to retrieve the list of tag values for ad-hoc filters
|
||||
getTagValues(options: DataSourceGetTagValuesOptions): Promise<Array<{ text: string }>> {
|
||||
getTagValues(options: DataSourceGetTagValuesOptions<TempoQuery>): Promise<Array<{ text: string }>> {
|
||||
return this.labelValuesQuery(options.key.replace(/^(resource|span)\./, ''));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user