0

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. How can i know, at a moment "t", how many of my metrics have this value above 0?

Lucas Ribeiro
  • 6,132
  • 2
  • 25
  • 28

2 Answers2

1

In the rendering endpoint, add format=json. This would return the data-points with corresponding epochs in JSON, which is a breeze to parse. The time-stamps wherein your script sent nothing will be NULL.

[{
 "target": "carbon.agents.ip-10-0-0-228-a.metricsReceived",
 "datapoints": 
  [
    [912, 1383888170], 
    [789, 1383888180], 
    [800, 1383888190], 
    [null, 1383888200], 
    [503, 1383888210], 
    [899, 1383888220]
  ]
}]
erbdex
  • 1,899
  • 3
  • 22
  • 40
  • Thnx @erbdex. That's one way to count it. It is better than what i have right now. I guess i didn't made myself clear. I want to represent this in a graphite graph. – Lucas Ribeiro Nov 08 '13 at 13:08
  • 1
    The DIY approach would be to write a simple script that calculates whatever you need and sends it back to statsd to chart a graph again (of graph-metadata). Nothing like the flexibility of this approach. – erbdex Nov 09 '13 at 16:17
0

You can use the currentAbove function. 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.


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.

For example, a way to get a quick count (using curl to pipe to grep and count on the word "target"). Like so:

> curl -silent http://test.net/render?target=currentAbove(stats.cronica.dragnet.messages.*, 5)&format=json \
> | grep -Po "target" | grep -c "target"
Matt Self
  • 19,520
  • 2
  • 32
  • 36
  • countSeries(*seriesLists) draws a horizontal line representing the number of nodes found in the seriesList. It is available from v0.9.10 onward. But i don't think that he wants to know how many wildcards got resolved. – erbdex Nov 20 '13 at 05:11
  • Nice. I didn't know about that function. In that case, a combo of currentAbove(around his original movingAverage etc) using 0 (to get metrics above 0), wrapped with countSeries would do the same as the script. Although perhaps I've misunderstood the question. – Matt Self Nov 20 '13 at 15:31
  • i guess he wants the flexibility of programming custom checks when he says "satisfy a certain condition". :) But yeah, don't really know. – erbdex Nov 20 '13 at 15:34