From d9897a457d8bebdf2f1fd59e3535d62b98c3e8af Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Wed, 14 Jul 2021 07:44:23 -0400 Subject: [PATCH] Loki: Add autocomplete option for $__range variable (#36717) * Add autocomplete option for Loki & Promtheus rates * Update test --- public/app/plugins/datasource/loki/language_provider.ts | 1 + .../plugins/datasource/prometheus/language_provider.test.ts | 3 ++- public/app/plugins/datasource/prometheus/promql.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/loki/language_provider.ts b/public/app/plugins/datasource/loki/language_provider.ts index 6cfc87c77f4..9e275687ea0 100644 --- a/public/app/plugins/datasource/loki/language_provider.ts +++ b/public/app/plugins/datasource/loki/language_provider.ts @@ -32,6 +32,7 @@ const NS_IN_MS = 1000000; // @see public/app/plugins/datasource/prometheus/promql.ts const RATE_RANGES: CompletionItem[] = [ { label: '$__interval', sortValue: '$__interval' }, + { label: '$__range', sortValue: '$__range' }, { label: '1m', sortValue: '00:01:00' }, { label: '5m', sortValue: '00:05:00' }, { label: '10m', sortValue: '00:10:00' }, diff --git a/public/app/plugins/datasource/prometheus/language_provider.test.ts b/public/app/plugins/datasource/prometheus/language_provider.test.ts index e29ca883f39..e1a3a485268 100644 --- a/public/app/plugins/datasource/prometheus/language_provider.test.ts +++ b/public/app/plugins/datasource/prometheus/language_provider.test.ts @@ -124,8 +124,9 @@ describe('Language completion provider', () => { expect(result.suggestions).toMatchObject([ { items: [ - { label: '$__interval', sortValue: '$__interval' }, // TODO: figure out why this row and sortValue is needed + { label: '$__interval', sortValue: '$__interval' }, { label: '$__rate_interval', sortValue: '$__rate_interval' }, + { label: '$__range', sortValue: '$__range' }, { label: '1m', sortValue: '00:01:00' }, { label: '5m', sortValue: '00:05:00' }, { label: '10m', sortValue: '00:10:00' }, diff --git a/public/app/plugins/datasource/prometheus/promql.ts b/public/app/plugins/datasource/prometheus/promql.ts index 681b481d75e..e8279c79e95 100644 --- a/public/app/plugins/datasource/prometheus/promql.ts +++ b/public/app/plugins/datasource/prometheus/promql.ts @@ -6,6 +6,7 @@ import { CompletionItem } from '@grafana/ui'; export const RATE_RANGES: CompletionItem[] = [ { label: '$__interval', sortValue: '$__interval' }, { label: '$__rate_interval', sortValue: '$__rate_interval' }, + { label: '$__range', sortValue: '$__range' }, { label: '1m', sortValue: '00:01:00' }, { label: '5m', sortValue: '00:05:00' }, { label: '10m', sortValue: '00:10:00' },