mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Implement PromQL Functions in new query editor (#45431)
* adding functions for prometheus queries * WIP: functions added. Just categorizing them and testing each function out * WIP: testing functions * WIP verifying other functions * Functions added and classified * added tests * moved bottomk to aggregations module * added tests to the PromQueryModeller * code review comments. Made range renderer common with code * removed duplicate functions * updated comments
This commit is contained in:
committed by
GitHub
parent
f42c830b3c
commit
abe32b9521
@@ -278,4 +278,40 @@ describe('PromQueryModeller', () => {
|
||||
})
|
||||
).toBe('metric_a / on(le) metric_b');
|
||||
});
|
||||
it('Can render functions that require a range as a parameter', () => {
|
||||
expect(
|
||||
modeller.renderQuery({
|
||||
metric: 'metric_a',
|
||||
labels: [],
|
||||
operations: [{ id: 'holt_winters', params: ['auto', 0.5, 0.5] }],
|
||||
})
|
||||
).toBe('holt_winters(metric_a[$__rate_interval], 0.5, 0.5)');
|
||||
});
|
||||
it('Can render functions that require parameters left of a range', () => {
|
||||
expect(
|
||||
modeller.renderQuery({
|
||||
metric: 'metric_a',
|
||||
labels: [],
|
||||
operations: [{ id: 'quantile_over_time', params: ['auto', 1] }],
|
||||
})
|
||||
).toBe('quantile_over_time(1, metric_a[$__rate_interval])');
|
||||
});
|
||||
it('Can render the label_join function', () => {
|
||||
expect(
|
||||
modeller.renderQuery({
|
||||
metric: 'metric_a',
|
||||
labels: [],
|
||||
operations: [{ id: 'label_join', params: ['label_1', ',', 'label_2'] }],
|
||||
})
|
||||
).toBe('label_join(metric_a, "label_1", ",", "label_2")');
|
||||
});
|
||||
it('Can render label_join with extra parameters', () => {
|
||||
expect(
|
||||
modeller.renderQuery({
|
||||
metric: 'metric_a',
|
||||
labels: [],
|
||||
operations: [{ id: 'label_join', params: ['label_1', ', ', 'label_2', 'label_3', 'label_4', 'label_5'] }],
|
||||
})
|
||||
).toBe('label_join(metric_a, "label_1", ", ", "label_2", "label_3", "label_4", "label_5")');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user