Skip to content

Instantly share code, notes, and snippets.

@torkelo
Created March 3, 2014 21:04
Show Gist options
  • Save torkelo/9334573 to your computer and use it in GitHub Desktop.
Save torkelo/9334573 to your computer and use it in GitHub Desktop.
var influx = require('influx');
var client = influx('localhost', 8086, 'root', 'root', 'site');
var data = {};
setInterval(function() {
randomWalk('request_count', 1000, 100);
randomWalk('request_count2', 1000, 100);
randomWalk('request_count3', 1000, 100);
randomWalk('request_time', 10, 5);
randomWalk('request_time2', 10, 5);
}, 10000);
function randomWalk(name, start, variation) {
if (!data[name]) {
data[name] = start;
}
data[name] += (Math.random() * variation) - (variation / 2);
console.log('Writing ' + name + " :" + data[name]);
client.writePoint(name, { time: new Date(), value: data[name] }, function(err) {
if (err) {
console.log('InfluxDB Error', err);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment