【问题标题】:how to get least possible count on graphite graph如何在石墨图上获得尽可能少的计数
【发布时间】:2013-10-11 12:43:13
【问题描述】:
require 'statsd'

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

1.times do
  statsd.increment 'hitcount4'
end

sleep 5

5.times do
  statsd.increment 'hitcount4'
end

sleep 10

10.times do
  statsd.increment 'hitcount4'
end

我正在使用 ruby​​ gem statsd-ruby

我运行了上面的脚本,它成功执行,图形出现了,但我只能看到 x 轴上的一条线,什么也没有(y 轴没有值),如何获取上面脚本的图形?

我想记录每个增量调用。

/opt/graphite/statsd/local.js 的内容

{
  graphitePort: 2003
, graphiteHost: "127.0.0.1"
, port: 8125
, backends: [ "./backends/graphite", "./backends/repeater", "./backends/console" ]
, repeater: [ { host: '10.1.2.15', port: 8125 } ]
, graphite: { legacyNamespace: false, globalPrefix: "rtpg.testing_server_2" }
, flushInterval: 10
}

/opt/graphite/conf/storage-schemas.conf 的内容

[carbon]
pattern = ^carbon\.
retentions = 60:90d

[stats]
pattern = ^stats.*
retentions = 1s:6h,10min:10d,10min:5y

[rtpg]
pattern = ^rtpg.*
retentions = 1s:7d,10s:21d,60s:5y

/opt/graphite/conf/storage-aggregation.conf 的内容

[rtpg]
pattern = .*
xFilesFactor = 0
aggregationMethod = sum


[sum]
pattern = \.count$
xFilesFactor = 0
aggregationMethod = sum

与,

localhost:8090/render?target=rtpg.testing_server_2.counters.account.hitcount4.count&format=raw

在浏览器上输出 =>

........0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 ,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0

//localhost:8090/render?target=rtpg.testing_server_2.counters.account.hitcount4.count&format=json

输出 =>

.......[0.0, 1381608024], [0.0, 1381608025], [0.0, 1381608026], [0.0, 1381608027], [0.0, 1381608028], [0.0, 1381608029], [0.0, 1381608030], [0.0, 1381608031], [0.0, 1381608032], [0.0, 1381608033], [0.0, 1381608034], [0.0, 1381608035], [0.0, 1381608036], [0.0, 1381608037], [0.0, 1381608038], [0.0, 1381608039], [0.0, 1381608040], [0.0, 1381608041], [0.0, 1381608042], [0.0, 1381608043], [0.0, 1381608044], [0.0, 1381608045], [0.0, 1381608046], [0.0, 1381608047], [0.0, 1381608048], [0.0, 1381608049], [0.0, 1381608050], [0.0, 1381608051], [0.0, 1381608052], [0.0, 1381608053], [0.0, 1381608054], [0.0, 1381608055], [0.0, 1381608056]]}]

我将flush intervel(statsd)更新为6000,并更新了

/opt/graphite/conf/storage-schemas.conf

[carbon]
pattern = ^carbon\.
retentions = 60:90d

[rtpg]
pattern = ^rtpg.*
retentions = 1m:6h,1m:7d,10m:5y

然后在我的脚本中运行 Whitper-resize.py 并将计数器名称更新为“hitcount6”并再次运行脚本,创建了一个新图表,问题仍然存在,实际上我想要的是石墨显示准确的计数增量,然后睡眠 5 分钟,然后 5 增量等等,我不想平均我的数据,最后我将创建一个 xml 报告,说明调用了多少次增量方法。 $ Whisper-info.py /opt/graphite/storage/whisper/rtpg/testing_server_2/counters/account/hitcount6/count.wsp

maxRetention: 604800
xFilesFactor: 0.0
aggregationMethod: sum
fileSize: 120988

Archive 0
retention: 604800
secondsPerPoint: 60
points: 10080
size: 120960
offset: 28

【问题讨论】:

  • 如果您“拆分” url 并将 &format=json 或 &format=raw 添加到查询字符串的末尾,您是否在石墨中看到(非空)值?
  • @MattSelf 是的,我收到了0.0
  • @MattSelf 更新了问题,提供了更多信息。

标签: ruby graphite statsd


【解决方案1】:

长话短说:使用 Graphite 作为后端时,您不能以低于 1 秒的间隔刷新 Statsd。

由于您指定了 10 毫秒的 flushInterval,StatsD 将每 10 毫秒刷新一次聚合数据点,其中 Graphite 将在 100 个中删除 99 个(除了 10 毫秒的刷新中的一个)。

首先,将其设置为如此低会破坏 Statsd 的某些目的,因为它旨在充当可以减少石墨负载的聚合器。 ,将其设置为低于 1 秒的任何值都会导致度量数据丢失。这是因为您可以在 Graphite 中存储的最高精度是 1 秒。因此,您每秒将向石墨发送 100 个数据点,而 Graphite 只会存储其中的 1 个。您必须非常幸运才能看到任何数据(因为它将采用最后一个指标(覆盖其他指标)作为间隔。

您必须将 StatsD 中的刷新间隔与 Graphite 中最精确的模式设置相匹配(在存储模式配置中)。您可以达到的最低值是 1 秒,但建议使用 10 秒,以便 StatsD 可以代表您完成一些重要的聚合工作。

我建议您将最好的(第一)精度更改为 10 秒,即 10s:6h10s:7d 用于保留(并将 Statsd flushInterval 更改为 10000 ms),以便 Statsd 和石墨排列整齐。

接下来,进行上述更改,然后调整耳语文件的大小以确保设置已完成。也许您在存储指标后更改了石墨模式或聚合设置(在耳语 = 石墨的存储中),您仍然需要删除指标的 .wsp 文件(石墨将重新创建它们)或运行whisper-resize.py。耳语文件位于/graphite/storage/whisper/

最后验证设置。您可以通过在 .wsp 文件上运行 Whisper-info.py 来针对某些耳语数据验证设置。在 /graphite/storage/whisper/ 中找到您的指标之一的 .wsp 文件 运行:whisper-info.py my_metric_data.wsp。 Whisper-info.py 输出应该告诉你更多关于存储设置是如何工作的。

【讨论】:

  • 仍然是同样的问题,但 /opt/graphite/statsd/local.js 中还有一件事,flushInterval: 10,是毫秒而不是秒。
  • 看来存储模式保留设置仍然与 statsd 刷新间隔不匹配。我假设您的意思是 flushInterval 为 60000 毫秒(1 分钟)而不是 6000 毫秒(6 秒),此时它将与您的存储模式设置 1m:6h 匹配。这些值必须匹配。我会使用 10 秒 (10000) 的标准 statsd 刷新间隔和 10 秒:6 小时的存储模式最高精度,只是为了看看事情是否正常。之后,您可以攻击石墨中的存储粒度。最好是 1 秒,statsd 将管理聚合。
  • 仍有可能发生其他问题,但首先,您绝对需要确保从 Whisper-info 返回的 secondsPerPoint 等于 StatsD 中的 flushInterval。否则,您将丢失数据。
  • 终于得到了有趣的结果,它总结了计数(1 + 5 + 10 = 16),但我不希望这个我希望它独立显示1、5、10,我应该将 storage-aggregation.conf 中的 aggregationMethod 从 sum 更改为其他内容,请建议正确的方法。
  • 最后我不希望石墨在任何时候平均我的数据。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多