smira / go-statsd

Go statsd client library with zero allocation overhead, great performance and reconnects
MIT License
109 stars 18 forks source link

Integrate with telegraf and grafana to visualize EPS #22

Open thangld322 opened 4 years ago

thangld322 commented 4 years ago

Hello. I'm using your go-statsd to count events in my logs shipper app. Everytimes it receives an event, it increases stat.inputEvents by one. Then, every second, I push that counter to telegraf server. Then, I use grafana to visualize this stat: SELECT "value" FROM "stat_inputEvents" WHERE $timeFilter GROUP BY time($interval)

My settings is: statsd.NewClient(statsdHost + ":" + strconv.Itoa(statsdPort), statsd.MaxPacketSize(400), statsd.MetricPrefix(""), statsd.FlushInterval(time.Second))

Since I flush it every second. Shouldn't this graph show Events Per Second of my shipper? But it has almost 300k EPS average while the source that provides events to my shipper only has 60k EPS... Can you tell me what I did wrong here please? Thank you so much!

smira commented 4 years ago

Hi @thangld322!

go-statsd as a library doesn't do any aggregation on the metrics. So if you increase some counter by one 1000 times, it sends one thousand increments for the counter to the server. Flush interval is only used to flush packets to the server if there's not enough data yet to build a full packet. So it controls maximum latency for metric. Usually there's some kind of aggregation between statsd client and time-series database which might affect the queries you're using.