[英]Count how many metrics matches a condition in graphite
I have a list of classes that extracts info from the web. 我有一个从网络中提取信息的类的列表。 Every time each one of them saves something, it sends a different counter to graphite.
他们每个人每次保存一些东西时,都会向石墨发送不同的计数器。 So, every one of them is a different metric.
因此,它们每个都是不同的指标。
How do I know how many of them satisfy a certain condition?? 我怎么知道其中有多少满足特定条件?
For example, let: 例如,让:
movingAverage(summarize(groupByNode(counters.crawlers.*.saved, 2, "sumSeries), "1hour"), 24)
be the average of content download in past 24 hours. 是过去24小时内容下载的平均值。 How can i know, at a moment "t", how many of my metrics have this value above 0?
在“ t”时刻,我怎么知道我有多少个指标的此值大于0?
In the rendering endpoint, add format=json
. 在呈现端点中,添加
format=json
。 This would return the data-points with corresponding epochs in JSON, which is a breeze to parse. 这将在JSON中返回具有相应历元的数据点,这很容易解析。 The time-stamps wherein your script sent nothing will be NULL.
您的脚本未发送任何内容的时间戳记将为NULL。
[{
"target": "carbon.agents.ip-10-0-0-228-a.metricsReceived",
"datapoints":
[
[912, 1383888170],
[789, 1383888180],
[800, 1383888190],
[null, 1383888200],
[503, 1383888210],
[899, 1383888220]
]
}]
You can use the currentAbove
function. 您可以使用
currentAbove
函数。 Check it out . 看看吧 。 For example:
例如:
currentAbove(stats.route.*.servertime.*, 5)
The above example gets all of the metrics (in the series) that are above 5. 上面的示例获取了高于5的所有指标(系列中)。
You could then count the number of targets returned, and while Graphite doesn't provide a way to count the "buckets" you should be able to capture it fairly easily. 然后,您可以计算返回的目标数量,而Graphite没有提供计算“存储桶”的方法,您应该可以轻松地捕获它。
For example, a way to get a quick count (using curl to pipe to grep and count on the word "target"). 例如,一种获得快速计数的方法(使用curl将其通过管道传递到grep并依靠单词“ target”)。 Like so:
像这样:
> curl -silent http://test.net/render?target=currentAbove(stats.cronica.dragnet.messages.*, 5)&format=json \
> | grep -Po "target" | grep -c "target"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.