The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/prometheus/tracking.ts

46 lines
1.7 KiB

import { CoreApp, DataQueryRequest, DataQueryResponse } from '@grafana/data';
import { reportInteraction, config } from '@grafana/runtime';
import { PromQuery } from './types';
export function trackQuery(
response: DataQueryResponse,
request: DataQueryRequest<PromQuery> & { targets: PromQuery[] },
startTime: Date
): void {
const { app, targets: queries } = request;
// We do want to track panel-editor and explore
// We do not want to track queries from the dashboard or viewing a panel
// also included in the tracking is cloud-alerting, unified-alerting, and unknown
if (app === CoreApp.Dashboard || app === CoreApp.PanelViewer) {
return;
}
for (const query of queries) {
reportInteraction('grafana_prometheus_query_executed', {
app,
grafana_version: config.buildInfo.version,
has_data: response.data.some((frame) => frame.length > 0),
has_error: response.error !== undefined,
expr: query.expr,
format: query.format,
instant: query.instant,
range: query.range,
exemplar: query.exemplar,
hinting: query.hinting,
interval: query.interval,
intervalFactor: query.intervalFactor,
utcOffsetSec: query.utcOffsetSec,
legend: query.legendFormat,
valueWithRefId: query.valueWithRefId,
requestId: request.requestId,
showingGraph: query.showingGraph,
showingTable: query.showingTable,
editor_mode: query.editorMode,
simultaneously_sent_query_count: queries.length,
time_range_from: request?.range?.from?.toISOString(),
time_range_to: request?.range?.to?.toISOString(),
time_taken: Date.now() - startTime.getTime(),
});
}
}