Skip to main content
 首页 » 编程设计

python之Graphite之使用 DivideSeries 的多个系列

2025年05月04日9itcoder

我正在尝试使用 Graphite 计算我所有资源的点击率,因此我尝试像这样记录我的数据:

  • ctr.resource_id.clicks
  • ctr.resource_id.reach

所以首先,我提出了我的疑问:

&target= averageSeries(divideSeries(ctr.176983011340976128.clicks,ctr.176983011340976128.reach),divideSeries(ctr.190348137012011008.clicks,ctr.190348137012011008.reach)) 

我的问题是我不想将我所有的资源 ID 发送到 Graphite,所以我尝试了:

&target= averageSeries(divideSeries(ctr.*.clicks,ctr.*.reach)) 

但是,是的,作为 documentation说“ValueError:divideSeries 第二个参数必须恰好引用 1 个系列”。

我尝试了另一种架构:

  • 点击率.resource_id
  • ctr.reach.resource_id

但是同样的问题...

我是 Graphite 的新手,所以如果有人有解决方案,那就太棒了!

编辑:

刚看到函数groupByNode , 尝试使用它……

请您参考如下方法:

听起来您需要事先将数据聚合成一个系列,以便将其传递给 divideSeries。

配置 Carbon 文档中的 Aggregator-rules.conf 引用:http://graphite.readthedocs.org/en/latest/config-carbon.html

所以您需要 2 个这样的规则来汇总每分钟的点击数据: ctr.resource_all.clicks (60) = sum ctr.*.clicks ctr.resource_all.reach (60) = sum ctr.*.reach

您还必须运行 carbon-aggregator.py 守护程序 /opt/graphite/bin/carbon-aggregator.py 开始

聚合器守护程序的默认端口是 2023,因此您应该将流量发送到该端口,而不是您一直使用的 2003 端口。