我已经用 Graphite 安装了 statsd。
我写了一个增加计数器的示例(请参见下文)。
我期待在 60 上看到一条线,因为我每秒增加一个计数器,但是我得到的线有点随机,范围在 14-29 之间。下面你可以看到图表的截图。
如何将图表更改为每 1 分钟显示 60 个?
/etc/statsd/localConfig.js 的内容
{
graphitePort: 2003
, graphiteHost: "localhost"
, port: 8125
, flushInterval: 60000
, graphite: {
legacyNamespace: false
}
}
storage-schemas.conf 的内容
[statsd]
pattern = ^stats\.
retentions = 60s:90d
[carbon]
pattern = ^carbon\.
retentions = 60:90d
[default_1min_for_1day]
pattern = .*
retentions = 60s:14d
storage-aggregation.conf 的内容
[min]
pattern = \.min$
xFilesFactor = 0.1
aggregationMethod = min
[max]
pattern = \.max$
xFilesFactor = 0.1
aggregationMethod = max
[count]
pattern = \.count$
xFilesFactor = 0
aggregationMethod = sum
[lower]
pattern = \.lower(_\d+)?$
xFilesFactor = 0.1
aggregationMethod = min
[upper]
pattern = \.upper(_\d+)?$
xFilesFactor = 0.1
aggregationMethod = max
[sum]
pattern = \.sum$
xFilesFactor = 0
aggregationMethod = sum
[gauges]
pattern = ^.*\.gauges\..*
xFilesFactor = 0
aggregationMethod = last
[default_average]
pattern = .*
xFilesFactor = 0.5
aggregationMethod = average
statsd 每分钟向石墨发送 60 个指标。
require 'statsd-ruby'
$statsd = Statsd.new '23.23.82.106', 8125
loop do
$statsd.increment 'xxx'
puts "sent at #{Time.now.strftime "%H:%M:%S"}"
sleep 1
end
图表如下所示: