Commit 8c39cd35 by Torkel Ödegaard

progress on interval built in variable

parent e2188373
...@@ -89,7 +89,7 @@ export function functionRenderer(part, innerExpr) { ...@@ -89,7 +89,7 @@ export function functionRenderer(part, innerExpr) {
var paramType = part.def.params[index]; var paramType = part.def.params[index];
if (paramType.type === 'time') { if (paramType.type === 'time') {
if (value === 'auto') { if (value === 'auto') {
value = '$interval'; value = '$__interval';
} }
} }
if (paramType.quote === 'single') { if (paramType.quote === 'single') {
......
...@@ -245,8 +245,8 @@ describe('templateSrv', function() { ...@@ -245,8 +245,8 @@ describe('templateSrv', function() {
initTemplateSrv([]); initTemplateSrv([]);
}); });
it('should replace $interval_ms with interval milliseconds', function() { it('should replace $__interval_ms with interval milliseconds', function() {
var target = _templateSrv.replace('10 * $interval_ms', {"interval_ms": {text: "100", value: "100"}}); var target = _templateSrv.replace('10 * $__interval_ms', {"__interval_ms": {text: "100", value: "100"}});
expect(target).to.be('10 * 100'); expect(target).to.be('10 * 100');
}); });
......
...@@ -42,6 +42,10 @@ function (angular, _, kbn) { ...@@ -42,6 +42,10 @@ function (angular, _, kbn) {
this._index[variable.name] = variable; this._index[variable.name] = variable;
} }
// default built ins
this._index['__interval'] = {text: '1s', value: '1s'};
this._index['__interval_ms'] = {text: '100', value: '100'};
}; };
this.variableInitialized = function(variable) { this.variableInitialized = function(variable) {
......
...@@ -66,7 +66,7 @@ function (queryDef) { ...@@ -66,7 +66,7 @@ function (queryDef) {
esAgg.format = "epoch_millis"; esAgg.format = "epoch_millis";
if (esAgg.interval === 'auto') { if (esAgg.interval === 'auto') {
esAgg.interval = "$interval"; esAgg.interval = "$__interval";
} }
if (settings.missing) { if (settings.missing) {
......
...@@ -23,7 +23,7 @@ export default class InfluxQuery { ...@@ -23,7 +23,7 @@ export default class InfluxQuery {
target.resultFormat = target.resultFormat || 'time_series'; target.resultFormat = target.resultFormat || 'time_series';
target.tags = target.tags || []; target.tags = target.tags || [];
target.groupBy = target.groupBy || [ target.groupBy = target.groupBy || [
{type: 'time', params: ['$interval']}, {type: 'time', params: ['$__interval']},
{type: 'fill', params: ['null']}, {type: 'fill', params: ['null']},
]; ];
target.select = target.select || [[ target.select = target.select || [[
......
...@@ -12,7 +12,7 @@ describe('InfluxQuery', function() { ...@@ -12,7 +12,7 @@ describe('InfluxQuery', function() {
}, templateSrv, {}); }, templateSrv, {});
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($interval) fill(null)'); expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($__interval) fill(null)');
}); });
}); });
...@@ -24,7 +24,7 @@ describe('InfluxQuery', function() { ...@@ -24,7 +24,7 @@ describe('InfluxQuery', function() {
}, templateSrv, {}); }, templateSrv, {});
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "5m_avg"."cpu" WHERE $timeFilter GROUP BY time($interval) fill(null)'); expect(queryText).to.be('SELECT mean("value") FROM "5m_avg"."cpu" WHERE $timeFilter GROUP BY time($__interval) fill(null)');
}); });
}); });
...@@ -43,7 +43,7 @@ describe('InfluxQuery', function() { ...@@ -43,7 +43,7 @@ describe('InfluxQuery', function() {
}, templateSrv, {}); }, templateSrv, {});
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") /100 AS "text" FROM "cpu" WHERE $timeFilter GROUP BY time($interval) fill(null)'); expect(queryText).to.be('SELECT mean("value") /100 AS "text" FROM "cpu" WHERE $timeFilter GROUP BY time($__interval) fill(null)');
}); });
}); });
...@@ -58,7 +58,7 @@ describe('InfluxQuery', function() { ...@@ -58,7 +58,7 @@ describe('InfluxQuery', function() {
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "hostname" = \'server\\\\1\' AND $timeFilter' expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "hostname" = \'server\\\\1\' AND $timeFilter'
+ ' GROUP BY time($interval)'); + ' GROUP BY time($__interval)');
}); });
it('should switch regex operator with tag value is regex', function() { it('should switch regex operator with tag value is regex', function() {
...@@ -69,7 +69,7 @@ describe('InfluxQuery', function() { ...@@ -69,7 +69,7 @@ describe('InfluxQuery', function() {
}, templateSrv, {}); }, templateSrv, {});
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "app" =~ /e.*/ AND $timeFilter GROUP BY time($interval)'); expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "app" =~ /e.*/ AND $timeFilter GROUP BY time($__interval)');
}); });
}); });
...@@ -83,7 +83,7 @@ describe('InfluxQuery', function() { ...@@ -83,7 +83,7 @@ describe('InfluxQuery', function() {
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "hostname" = \'server1\' AND "app" = \'email\' AND ' + expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "hostname" = \'server1\' AND "app" = \'email\' AND ' +
'$timeFilter GROUP BY time($interval)'); '$timeFilter GROUP BY time($__interval)');
}); });
}); });
...@@ -97,7 +97,7 @@ describe('InfluxQuery', function() { ...@@ -97,7 +97,7 @@ describe('InfluxQuery', function() {
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "hostname" = \'server1\' OR "hostname" = \'server2\' AND ' + expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "hostname" = \'server1\' OR "hostname" = \'server2\' AND ' +
'$timeFilter GROUP BY time($interval)'); '$timeFilter GROUP BY time($__interval)');
}); });
}); });
...@@ -124,7 +124,7 @@ describe('InfluxQuery', function() { ...@@ -124,7 +124,7 @@ describe('InfluxQuery', function() {
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter ' + expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter ' +
'GROUP BY time($interval), "host"'); 'GROUP BY time($__interval), "host"');
}); });
}); });
...@@ -148,7 +148,7 @@ describe('InfluxQuery', function() { ...@@ -148,7 +148,7 @@ describe('InfluxQuery', function() {
groupBy: [{type: 'time'}, {type: 'fill', params: ['0']}], groupBy: [{type: 'time'}, {type: 'fill', params: ['0']}],
}, templateSrv, {}); }, templateSrv, {});
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT "value" FROM "cpu" WHERE $timeFilter GROUP BY time($interval) fill(0)'); expect(queryText).to.be('SELECT "value" FROM "cpu" WHERE $timeFilter GROUP BY time($__interval) fill(0)');
}); });
}); });
......
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