prometheus: add builtin template variable as range vectors

add $__interval and $__interval_ms as range vectors to
prometheus editor
This commit is contained in:
bergquist
2017-10-18 14:03:23 +02:00
parent 9ae3938136
commit c2c5f529f3
2 changed files with 13 additions and 5 deletions
@@ -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');
});
});
});