Commit c2c5f529 by bergquist

prometheus: add builtin template variable as range vectors

add $__interval and $__interval_ms as range vectors to
prometheus editor
parent 9ae39381
......@@ -80,6 +80,8 @@ export class PromCompleter {
vectors.push({caption: value+unit, value: '['+value+unit, meta: 'range vector'});
}
}
vectors.push({caption: '$__interval', value: '[$__interval', meta: 'range vector'});
vectors.push({caption: '$__interval_ms', value: '[$__interval_ms', meta: 'range vector'});
callback(null, vectors);
return;
}
......
......@@ -44,12 +44,18 @@ describe('Prometheus editor completer', function() {
describe('When inside brackets', () => {
it('Should return range vectors', () => {
const session = getSessionStub({
currentToken: {},
tokens: [],
line: '',
currentToken: {type: 'paren.lparen', value: '[', index: 2, start: 9},
tokens: [
{type: 'identifier', value: 'node_cpu'},
{type: 'paren.lparen', value: '['}
],
line: 'node_cpu[',
});
completer.getCompletions(editor, session, {row: 0, column: 10}, '[', (s, res) => {
expect(res[0]).to.eql({caption: '1s', value: '[1s', meta: 'range vector'});
return completer.getCompletions(editor, session, {row: 0, column: 10}, '[', (s, res) => {
expect(res[0].caption).to.eql('1s');
expect(res[0].value).to.eql('[1s');
expect(res[0].meta).to.eql('range vector');
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment