Created
March 26, 2019 17:51
-
-
Save sysdig-blog/7fb94accfbf164a34fe8060b83d36304 to your computer and use it in GitHub Desktop.
Javascript code example with StatsD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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