Elasticsearch: Deprecate index setting for annotation queries (#67046)

* Elasticsearch: Deprecate index setting for annotation queries

* Update comment
This commit is contained in:
Ivana Huckova 2023-04-24 17:02:55 +02:00 committed by GitHub
parent efd0e9cbea
commit 0b2f7db224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View File

@ -52,7 +52,7 @@ import {
} from './components/QueryEditor/MetricAggregationsEditor/aggregations';
import { metricAggregationConfig } from './components/QueryEditor/MetricAggregationsEditor/utils';
import { defaultBucketAgg, hasMetricOfType } from './queryDef';
import { trackQuery } from './tracking';
import { trackAnnotationQuery, trackQuery } from './tracking';
import {
Logs,
BucketAggregation,
@ -321,7 +321,8 @@ export class ElasticDatasource
ignore_unavailable: true,
};
// old elastic annotations had index specified on them
// @deprecated
// Field annotation.index is deprecated and will be removed in the future
if (annotation.index) {
header.index = annotation.index;
} else {
@ -330,6 +331,7 @@ export class ElasticDatasource
const payload = JSON.stringify(header) + '\n' + JSON.stringify(data) + '\n';
trackAnnotationQuery(annotation);
return lastValueFrom(
this.post('_msearch', payload).pipe(
map((res) => {

View File

@ -140,3 +140,25 @@ export function trackQuery(
});
}
}
export function trackAnnotationQuery(annotation: {
target: ElasticsearchQuery;
timeField?: string;
timeEndField?: string;
query?: string;
tagsField?: string;
textField?: string;
index?: string;
[key: string]: unknown;
}): void {
reportInteraction('grafana_elasticsearch_annotation_query_executed', {
grafana_version: config.buildInfo.version,
has_target_query: !!annotation.target?.query,
has_query: !!annotation.query,
has_time_field: !!annotation.timeField,
has_time_end_field: !!annotation.timeEndField,
has_tags_field: !!annotation.tagsField,
has_text_field: !!annotation.textField,
has_index: !!annotation.index,
});
}