i'm collect data using Go and want to visualize it, i chose Datadog, but didn't find examples or live projects where Go used for sending metrics to Datadog. But in offical site says that Go is supported.
First step is to install the DataDog agent on the server in which you are running your application:
https://docs.datadoghq.com/agent/
You then need to enable the DogStatsD
service in the DataDog agent:
https://docs.datadoghq.com/developers/dogstatsd/
After that, you can send metrics to the statsd
agent using any Go library that connects to statsd
.
For example:
https://github.com/DataDog/datadog-go
https://github.com/go-kit/kit/tree/master/metrics/statsd
Here's an example program sending some counts using the first library:
import (
"github.com/DataDog/datadog-go/statsd"
"log"
)
func main() {
// Create the client
c, err := statsd.New("127.0.0.1:8125")
if err != nil {
log.Fatal(err)
}
// Prefix every metric with the app name
c.Namespace = "myapp."
// Count two events
err = c.Count("my_counter", 2, nil, 1)
if err != nil {
log.Fatal(err)
}
// Close the client
err = c.Close()
if err != nil {
log.Fatal(err)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With