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

Add ability to specify where clause to InfluxDB #76

Merged
merged 2 commits into from
Mar 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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