mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 02:10:45 -06:00
prometheus: query-editor: better duration-completions (#39284)
This commit is contained in:
parent
eefb5fe4ea
commit
f8de33da8d
@ -49,14 +49,21 @@ function getAllFunctionsCompletions(): Completion[] {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllDurationsCompletions(): Completion[] {
|
const DURATION_COMPLETIONS: Completion[] = [
|
||||||
// FIXME: get a better list
|
'$__interval',
|
||||||
return ['5m', '1m', '30s', '15s'].map((text) => ({
|
'$__range',
|
||||||
type: 'DURATION',
|
'$__rate_interval',
|
||||||
label: text,
|
'1m',
|
||||||
insertText: text,
|
'5m',
|
||||||
}));
|
'10m',
|
||||||
}
|
'30m',
|
||||||
|
'1h',
|
||||||
|
'1d',
|
||||||
|
].map((text) => ({
|
||||||
|
type: 'DURATION',
|
||||||
|
label: text,
|
||||||
|
insertText: text,
|
||||||
|
}));
|
||||||
|
|
||||||
async function getAllHistoryCompletions(dataProvider: DataProvider): Promise<Completion[]> {
|
async function getAllHistoryCompletions(dataProvider: DataProvider): Promise<Completion[]> {
|
||||||
// function getAllHistoryCompletions(queryHistory: PromHistoryItem[]): Completion[] {
|
// function getAllHistoryCompletions(queryHistory: PromHistoryItem[]): Completion[] {
|
||||||
@ -137,7 +144,7 @@ async function getLabelValuesForMetricCompletions(
|
|||||||
export async function getCompletions(intent: Intent, dataProvider: DataProvider): Promise<Completion[]> {
|
export async function getCompletions(intent: Intent, dataProvider: DataProvider): Promise<Completion[]> {
|
||||||
switch (intent.type) {
|
switch (intent.type) {
|
||||||
case 'ALL_DURATIONS':
|
case 'ALL_DURATIONS':
|
||||||
return getAllDurationsCompletions();
|
return DURATION_COMPLETIONS;
|
||||||
case 'ALL_METRIC_NAMES':
|
case 'ALL_METRIC_NAMES':
|
||||||
return getAllMetricNamesCompletions(dataProvider);
|
return getAllMetricNamesCompletions(dataProvider);
|
||||||
case 'FUNCTIONS_AND_ALL_METRIC_NAMES': {
|
case 'FUNCTIONS_AND_ALL_METRIC_NAMES': {
|
||||||
|
Loading…
Reference in New Issue
Block a user