Go
How to send metrics using GO
Sending a metric via TCP
import (
"fmt"
"net"
)
...
conn, err := net.Dial("tcp", "YOUR-UID.carbon.hostedgraphite.com:2003")
_, err = fmt.Fprintf(conn, "YOUR-API-KEY.foo.go-tcp 1.2\n")
// don't forget to handle the error and close connectionSending a metric via UDP
import (
"fmt"
"net"
)
...
conn, err := net.Dial("udp", "YOUR-UID.carbon.hostedgraphite.com:2003")
_, err = fmt.Fprintf(conn, "YOUR-API-KEY.foo.go-udp 1.2\n")
// don't forget to handle the error and close connectionSending a metric using HTTP
Your API key can be found on your account home page.
Last updated
Was this helpful?