Git Product home page Git Product logo

Comments (10)

rtkmhart avatar rtkmhart commented on July 28, 2024 1

I see what's going on, the timestamp that's sent with the metrics to graphite never changes. When I reverted the change from using ts = counter.Timestamp to using now := time.Now().Unix() everything works as it should. Adding a few more debug statements in graphite.go show that the timer.Timestamp doesn't change over time.

I suspect it's because in https://github.com/atlassian/gostatsd/blob/better-graphite-support/statsd/aggregator.go#L271 if the timer is found in a.Timers, the timestamp is never updated, it's only set when the timer is first created. Same pattern for the other receive*() methods.

from gostatsd.

ash2k avatar ash2k commented on July 28, 2024

Looks like out behaviour is significantly different from what original statsd does. Should make it more configurable and it should mimic the original behaviour of course.

from gostatsd.

ash2k avatar ash2k commented on July 28, 2024

@rtkmhart could you try better-graphite-support branch to verify it works for you?

from gostatsd.

rtkmhart avatar rtkmhart commented on July 28, 2024

Thanks for the quick response! Unfortunately the format the graphite backend sends out is like this

stats_counts.mike.test.counter %!f(int64=10) 1465832174
stats.mike.test.counter %!d(float64=0.9985744043244373) 1465832174

Setup to test this is as follows (all on the same host) with two config files:
config1.toml:

[statsdaemon]
    address = "localhost:9125"

config2.toml:

[graphite]
    address = "localhost:2003"
  • Run netcat pretending to be graphite: nc -lk 2003
  • Run instance with graphite backend: ./gostatsd --backends graphite --config-path ./config2.toml --console-addr ":9126" --flush-interval 10s --verbose --metrics-addr ":9125"
  • Run instance with statsd backend: ./gostatsd --backends "statsdaemon" --config-path ./config1.toml --console-addr ":8126" --flush-interval 10s --verbose
  • Send metrics: while [ 1 ]; do echo "mike.test.counter:1|c" | nc -uq1 localhost 8125; done

All output from netcat has the formatting string instead of a proper value.

from gostatsd.

rtkmhart avatar rtkmhart commented on July 28, 2024

I think the format strings are backwards for the Counters section, this seems to work for me. diff as follows:

diff --git a/backend/backends/graphite/graphite.go b/backend/backends/graphite/graphite.go
index 533bd8e..710cae1 100644
--- a/backend/backends/graphite/graphite.go
+++ b/backend/backends/graphite/graphite.go
@@ -119,8 +119,8 @@ func (client *client) preparePayload(metrics *types.MetricMap) *bytes.Buffer {
        if client.legacyNamespace {
                metrics.Counters.Each(func(key, tagsKey string, counter types.Counter) {
                        k := sk(key)
-                       fmt.Fprintf(buf, "stats_counts.%s%s %f %d\n", k, client.globalSuffix, counter.Value, now)
-                       fmt.Fprintf(buf, "%s%s%s %d %d\n", client.counterNamespace, k, client.globalSuffix, counter.PerSecond, now)
+                       fmt.Fprintf(buf, "stats_counts.%s%s %d %d\n", k, client.globalSuffix, counter.Value, now)
+                       fmt.Fprintf(buf, "%s%s%s %f %d\n", client.counterNamespace, k, client.globalSuffix, counter.PerSecond, now)
                })
        } else {
                metrics.Counters.Each(func(key, tagsKey string, counter types.Counter) {

from gostatsd.

ash2k avatar ash2k commented on July 28, 2024

@rtkmhart Yeah, it was incorrect. I wrote tests and caught few more issues. Could you try the same branch once again?

from gostatsd.

rtkmhart avatar rtkmhart commented on July 28, 2024

@ash2k Thanks! There's something odd about the graphite backend that I can't figure out yet. tcpdump and netcat show that the output to graphite from etsy/statsd and gostatsd is identical (i'm probably missing something?), but if I run some timer metrics through etsy/statsd and gostatsd, graphite happily stores everything from etsy/statsd and barely anything from gostatsd. I will keep digging, here's what I was doing to replicate:

  • Generate timers with random values: while [ 1 ]; do METRIC="mike.test.counter:$RANDOM|ms"; echo $METRIC; echo $METRIC | nc -uq1 localhost 8125; done
  • curl command against graphite: curl http://graphitehost/render/?target=stats.timers.mike.test.counter.mean&format=json&from=-5minute" |json_pp

When using etsy/statsd, every value is filled, but when gostatsd, almost none. Thoughts?

from gostatsd.

ash2k avatar ash2k commented on July 28, 2024

@rtkmhart I've pushed a fix, let me know if it works for you. Thanks!

from gostatsd.

rtkmhart avatar rtkmhart commented on July 28, 2024

@ash2k works perfectly, thank you!

from gostatsd.

ash2k avatar ash2k commented on July 28, 2024

@rtkmhart FYI I've just released 0.14.1 with this issue fixed.

from gostatsd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.