mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Do not track samples (#59960)
This commit is contained in:
parent
55055d0b9b
commit
1aa94165d9
@ -28,7 +28,7 @@ import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { initialCustomVariableModelState } from '../../../features/variables/custom/reducer';
|
||||
import { CustomVariableModel } from '../../../features/variables/types';
|
||||
|
||||
import { LokiDatasource } from './datasource';
|
||||
import { LokiDatasource, REF_ID_DATA_SAMPLES } from './datasource';
|
||||
import { createLokiDatasource, createMetadataRequest } from './mocks';
|
||||
import { parseToNodeNamesArray } from './queryUtils';
|
||||
import { LokiOptions, LokiQuery, LokiQueryType, LokiVariableQueryType } from './types';
|
||||
@ -946,7 +946,7 @@ describe('LokiDatasource', () => {
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
hideFromInspector: true,
|
||||
requestId: 'log-samples',
|
||||
requestId: REF_ID_DATA_SAMPLES,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -76,6 +76,7 @@ import { LokiVariableSupport } from './variables';
|
||||
export type RangeQueryOptions = DataQueryRequest<LokiQuery> | AnnotationQueryRequest<LokiQuery>;
|
||||
export const DEFAULT_MAX_LINES = 1000;
|
||||
export const LOKI_ENDPOINT = '/loki/api/v1';
|
||||
export const REF_ID_DATA_SAMPLES = 'loki-data-samples';
|
||||
const NS_IN_MS = 1000000;
|
||||
|
||||
function makeRequest(
|
||||
@ -419,13 +420,13 @@ export class LokiDatasource
|
||||
const lokiLogsQuery: LokiQuery = {
|
||||
expr: query.expr,
|
||||
queryType: LokiQueryType.Range,
|
||||
refId: 'log-samples',
|
||||
refId: REF_ID_DATA_SAMPLES,
|
||||
maxLines: 10,
|
||||
};
|
||||
|
||||
// For samples, we use defaultTimeRange (now-6h/now) and limit od 10 lines so queries are small and fast
|
||||
const timeRange = getDefaultTimeRange();
|
||||
const request = makeRequest(lokiLogsQuery, timeRange, CoreApp.Explore, 'log-samples', true);
|
||||
const request = makeRequest(lokiLogsQuery, timeRange, CoreApp.Unknown, REF_ID_DATA_SAMPLES, true);
|
||||
return await lastValueFrom(this.query(request).pipe(switchMap((res) => of(res.data))));
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { variableRegex } from 'app/features/variables/utils';
|
||||
|
||||
import { QueryEditorMode } from '../prometheus/querybuilder/shared/types';
|
||||
|
||||
import { REF_ID_DATA_SAMPLES } from './datasource';
|
||||
import pluginJson from './plugin.json';
|
||||
import { getNormalizedLokiQuery, isLogsQuery, parseToNodeNamesArray } from './queryUtils';
|
||||
import { LokiQuery, LokiQueryType } from './types';
|
||||
@ -119,6 +120,9 @@ const isQueryWithChangedLegend = (query: LokiQuery): boolean => {
|
||||
|
||||
export function trackQuery(response: DataQueryResponse, queries: LokiQuery[], app: string): void {
|
||||
for (const query of queries) {
|
||||
if (query.refId === REF_ID_DATA_SAMPLES) {
|
||||
return;
|
||||
}
|
||||
reportInteraction('grafana_loki_query_executed', {
|
||||
app,
|
||||
editor_mode: query.editorMode,
|
||||
|
Loading…
Reference in New Issue
Block a user