Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Add tag support to v09 assembleEvent
Browse files Browse the repository at this point in the history
Any metric prepended with __t__ will be viewed as a tag
  • Loading branch information
rjaquino committed Aug 10, 2015
1 parent 94b884d commit cc75147
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/influxdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,34 @@ InfluxdbBackend.prototype.assembleEvent_v08 = function (name, events) {

InfluxdbBackend.prototype.assembleEvent_v09 = function (name, events) {
var self = this;
var tag_symbol = "__t__";
var measurement_pieces = [];
var tags = {};
var pieces = name.split(".");

var i = 0;
while (i < pieces.length) {
if (pieces[i].substr(0,tag_symbol.length) == tag_symbol) {
var tag = pieces[i].substr(tag_symbol.length);
tags[tag] = pieces[i+1];
i += 2;
}
else {
measurement_pieces.push(pieces[i]);
i++;
}
}

var measurement = measurement_pieces.join(".");

var payload = {
measurement: name,
fields: { value: events[0]['value'] }
measurement: measurement,
fields: { value: events[0]['value'] },
tags: tags
}

return payload;

}

InfluxdbBackend.prototype.httpPOST_v08 = function (points) {
Expand Down

0 comments on commit cc75147

Please sign in to comment.