how to get least possible count on graphite graph

后端 未结 1 1388
陌清茗
陌清茗 2021-01-16 10:14
require \'statsd\'

statsd = Statsd.new(\'localhost\', 8125).tap{|sd| sd.namespace = \'account\'}

1.times do
  statsd.increment \'hitcount4\'
end

sleep 5

5.times          


        
相关标签:
1条回答
  • 2021-01-16 10:39

    Long story short: You cannot flush Statsd at an interval lower than 1 second when using Graphite as the backend.

    Because you've specified a flushInterval of 10 ms, StatsD will flush the aggregated data-point every 10 milliseconds of which Graphite will drop 99 out of 100 (all but one of the 10ms flushes).

    First, setting it this low defeats some of the purpose of Statsd in that it is intended to act as an aggregator that can reduce load on graphite. Second, setting it to anything lower than 1 second will result in lost metric data. This is because the finest precision that you can store in Graphite is 1 second. So you'll send 100 data points to graphite per second and Graphite will only store 1 of them. You'd have to be pretty lucky to see any data (as it will take the last metric (overwriting the others) for the interval.

    You must match the flush interval in StatsD to the finest precision schema setting in Graphite (in the storage-schema configuration). The lowest you can go is one second, but 10 seconds is recommended so that StatsD can do some significant aggregation work on your behalf.

    I'd recommend you change the finest (first) precision to 10 seconds, i.e. 10s:6h and 10s:7d for the retentions (and the Statsd flushInterval to 10000 ms) so that Statsd and Graphite line up nicely.

    Next, make the above change and then resize the whisper files to ensure the settings have taken. Perhaps you changed the graphite schema or aggregation settings after metrics were stored (in whisper = graphite's storage) and you still need to either delete the .wsp files for the metric (graphite will recreate them) or run whisper-resize.py. The whisper files are in /graphite/storage/whisper/.

    Finally, validate the settings. You can verify the settings against some whisper data by running whisper-info.py on a .wsp file. Find the .wsp file for one of your metrics in /graphite/storage/whisper/ Run: whisper-info.py my_metric_data.wsp. whisper-info.py output should tell you more about how the storage settings are working.

    0 讨论(0)
提交回复
热议问题