Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 84f9586

Browse files
committed
Merge pull request #76 from darkhelmet/influxdb-where
Add ability to specify where clause to InfluxDB
2 parents 21ef666 + 62e2a8b commit 84f9586

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Metric-level attributes are attributes of the metric object(s) in your `metrics`
9898
* unit - Arbitrary string that can be used to designate a unit value; for example, "Mbps". (optional)
9999
* series - Name of the InfluxDB series that each target belongs to. (mandatory for InfluxDB)
100100
* transform - A function that takes the value and returns a transformed value. (optional)
101+
* where - A `where` clause to pass to InfluxDB. (optional for InfluxDB)
101102

102103
## Deployment
103104

lib/tasseo/public/j/tasseo.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ TasseoInfluxDBDatasource.prototype = {
276276
urlForMetric: function(metric, period) {
277277
var self = this;
278278

279-
return this.url + '/series?time_precision=s&u=' + self.user + '&p=' + self.pass + '&q=select%20' + metric.target + '%20from%20' + metric.series + '%20where%20time%20%3E%20now()%20-%20' + period + 'm%3B';
279+
var query = 'select ' + metric.target + ' from ' + metric.series + ' where time > now() - 5m';
280+
if (metric.where) {
281+
query += ' and (' + metric.where + ')';
282+
}
283+
284+
return this.url + '/series?time_precision=s&u=' + self.user + '&p=' + self.pass + '&q=' + escape(query)
280285
}
281286
}
282287

0 commit comments

Comments
 (0)