diff --git a/public/app/plugins/datasource/elasticsearch/datasource.ts b/public/app/plugins/datasource/elasticsearch/datasource.ts index cdf73047d0b..6de79c1b9e0 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.ts @@ -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) => { diff --git a/public/app/plugins/datasource/elasticsearch/tracking.ts b/public/app/plugins/datasource/elasticsearch/tracking.ts index ac14a4a1ed1..720a7eef24c 100644 --- a/public/app/plugins/datasource/elasticsearch/tracking.ts +++ b/public/app/plugins/datasource/elasticsearch/tracking.ts @@ -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, + }); +}