Node.js

Sending a metric via TCP

var net = require("net");

var socket = net.createConnection(2003, "YOUR-UID.carbon.hostedgraphite.com", function() {
    socket.write("YOUR-API-KEY.foo 1.2\n");
    socket.end();
});

Sending a metric via UDP

// For Nodejs v10
var dgram = require("dgram");

var message = Buffer.from("YOUR-API-KEY.foo 1.2\n")
var client = dgram.createSocket("udp4");
client.send(message, 0, message.length, 2003, "YOUR-UID.carbon.hostedgraphite.com", function(err, bytes) {
    client.close();
});

Your API key can be found on your account home page.