我正在使用statsd(git主分支上的最新版本)与graphite(0.9.10)作为后端。
在我的(Django)代码中,当用户注册时,我调用statsd.incr(“signups”)
。在Graphite的Web界面中,我现在可以看到一个美丽的图表,显示每秒注册的次数在Graphite / stats / signups下。当我查看Graphite / stats_counts / signups下的图表时,我希望看到总注册人数,但它似乎是每10秒间隔的注册数量(我猜这是Statsd的刷新间隔)。
我确实配置了storage-aggregation.conf
,也许我做错了什么?此外,我停止了carbon(不是用stop
,而是真正终止了它,因为显然只停止它不允许它重新加载配置)。 我还删除了/opt/graphite/storage/whisper/stats_counts
目录。 然后,我重新启动了carbon守护程序。 但我仍然得到每10秒间隔的注册次数。 :-(
这是我的配置:
# /opt/graphite/conf/storage-aggregation.conf
[lower]
pattern = \.lower$
xFilesFactor = 0.1
aggregationMethod = min
[upper]
pattern = \.upper$
xFilesFactor = 0.1
aggregationMethod = max
[upper_90]
pattern = \.upper_90$
xFilesFactor = 0.1
aggregationMethod = max
[count]
pattern = \.count$
xFilesFactor = 0
aggregationMethod = sum
[count_ps]
pattern = \.count_ps$
xFilesFactor = 0
aggregationMethod = sum
[sum]
pattern = \.sum$
xFilesFactor = 0
aggregationMethod = sum
[sum_90]
pattern = \.sum_90$
xFilesFactor = 0
aggregationMethod = sum
[stats_counts]
pattern = ^stats_counts\.
xFilesFactor = 0
aggregationMethod = sum
[min]
pattern = \.min$
xFilesFactor = 0.1
aggregationMethod = min
[max]
pattern = \.max$
xFilesFactor = 0.1
aggregationMethod = max
[default_average]
pattern = .*
xFilesFactor = 0.5
aggregationMethod = average
And this:
# /opt/graphite/conf/storage-schemas.conf
[stats]
priority = 110
pattern = ^stats.*
retentions = 10s:6h,1m:7d,10m:1y
我开始觉得我做的一切都是正确的,Graphite确实在执行它应该执行的任务。所以问题来了:
配置statsd和graphite以绘制自时间开始的总注册数的合适方法是什么?
我猜我可以改变我的Django代码定期计算用户总数,然后使用gauge
代替incr
,但感觉graphite应该能够即时地对接收到的所有数据进行求和,而不仅仅在聚合数据时。
编辑:
在Graphite的Web界面中,在Graphite/stats/signups中的基本“每秒注册”图表上应用了integral
函数,并获得了所需的图表(即总注册数)。这是获取累积图的适当方法吗?这很烦人,因为必须选择从一开始的完整日期范围,不能缩放图表,否则只能获得缩放部分的积分。 :-(