Skip to content

Instantly share code, notes, and snippets.

@sohamkamani
Created June 28, 2018 06:22
Show Gist options
  • Save sohamkamani/5aa2461cc197c3a51a169c4add5c38c7 to your computer and use it in GitHub Desktop.
Save sohamkamani/5aa2461cc197c3a51a169c4add5c38c7 to your computer and use it in GitHub Desktop.
sending metrics to statsd via udp in Go
func main() {
conn, err := net.Dial("udp", "127.0.0.1:8125")
if err != nil {
fmt.Printf("Some error %v", err)
return
}
for i := 0; i < 10; i++ {
// This is the only line of code you need to push stats to telegraf
fmt.Fprintf(conn, "deploys.test.myservice,from=go:1|c")
time.Sleep(1 * time.Second)
}
conn.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment