Skip to content

Commit

Permalink
PoC add rate_interval_ms as rate range in prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
gtk-grafana committed Jul 25, 2023
1 parent 6e1910e commit 7d4ec70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions public/app/plugins/datasource/loki/LanguageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const NS_IN_MS = 1000000;
const RATE_RANGES: CompletionItem[] = [
{ label: '$__interval', sortValue: '$__interval' },
{ label: '$__range', sortValue: '$__range' },
{ label: '$__range', sortValue: '$__range' },
{ label: '1m', sortValue: '00:01:00' },
{ label: '5m', sortValue: '00:05:00' },
{ label: '10m', sortValue: '00:10:00' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { escapeLabelValueInExactSelector } from '../../../language_utils';
import { FUNCTIONS } from '../../../promql';
import { FUNCTIONS, RATE_RANGES } from '../../../promql';

import type { Situation, Label } from './situation';
import { NeverCaseError } from './util';
Expand Down Expand Up @@ -57,20 +57,10 @@ async function getAllFunctionsAndMetricNamesCompletions(dataProvider: DataProvid
return [...FUNCTION_COMPLETIONS, ...metricNames];
}

const DURATION_COMPLETIONS: Completion[] = [
'$__interval',
'$__range',
'$__rate_interval',
'1m',
'5m',
'10m',
'30m',
'1h',
'1d',
].map((text) => ({
const DURATION_COMPLETIONS: Completion[] = RATE_RANGES.map((text) => ({
type: 'DURATION',
label: text,
insertText: text,
label: text.label,
insertText: text.label,
}));

async function getAllHistoryCompletions(dataProvider: DataProvider): Promise<Completion[]> {
Expand Down
1 change: 1 addition & 0 deletions public/app/plugins/datasource/prometheus/promql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CompletionItem } from '@grafana/ui';
export const RATE_RANGES: CompletionItem[] = [
{ label: '$__interval', sortValue: '$__interval' },
{ label: '$__rate_interval', sortValue: '$__rate_interval' },
{ label: '$__rate_interval_ms', sortValue: '$__rate_interval_ms' },
{ label: '$__range', sortValue: '$__range' },
{ label: '1m', sortValue: '00:01:00' },
{ label: '5m', sortValue: '00:05:00' },
Expand Down

0 comments on commit 7d4ec70

Please sign in to comment.