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

Commit

Permalink
Merge pull request #76 from darkhelmet/influxdb-where
Browse files Browse the repository at this point in the history
Add ability to specify where clause to InfluxDB
  • Loading branch information
obfuscurity committed Mar 28, 2014
2 parents 21ef666 + 62e2a8b commit 84f9586
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Metric-level attributes are attributes of the metric object(s) in your `metrics`
* unit - Arbitrary string that can be used to designate a unit value; for example, "Mbps". (optional)
* series - Name of the InfluxDB series that each target belongs to. (mandatory for InfluxDB)
* transform - A function that takes the value and returns a transformed value. (optional)
* where - A `where` clause to pass to InfluxDB. (optional for InfluxDB)

## Deployment

Expand Down
7 changes: 6 additions & 1 deletion lib/tasseo/public/j/tasseo.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ TasseoInfluxDBDatasource.prototype = {
urlForMetric: function(metric, period) {
var self = this;

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';
var query = 'select ' + metric.target + ' from ' + metric.series + ' where time > now() - 5m';
if (metric.where) {
query += ' and (' + metric.where + ')';
}

return this.url + '/series?time_precision=s&u=' + self.user + '&p=' + self.pass + '&q=' + escape(query)
}
}

Expand Down

0 comments on commit 84f9586

Please sign in to comment.