Skip to content

Instantly share code, notes, and snippets.

@sysdig-blog
Created March 26, 2019 17:51
Show Gist options
  • Save sysdig-blog/7fb94accfbf164a34fe8060b83d36304 to your computer and use it in GitHub Desktop.
Save sysdig-blog/7fb94accfbf164a34fe8060b83d36304 to your computer and use it in GitHub Desktop.
Javascript code example with StatsD
const SDC = require('statsd-client');
const sdc = new SDC({host: '127.0.0.1'});
setInterval(() => {
const timer = new Date();
// Increment counter by one.
sdc.increment('node.counter');
// Increment counter by 10
sdc.increment('node.counter_10', 10);
// Set gauge to 10
sdc.gauge('node.gauge', 10);
// Calculates time diff of time between the variable and
// when the function was called
sdc.timing('node.timer', timer);
// Set will count just 2 elements since '50' is repeated
sdc.set('node.set', 50);
sdc.set('node.set', 100);
sdc.set('node.set', 50);
// Histogram with tags
sdc.histogram('node.histogram', 10, {foo: 'bar'});
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment