0

I have success and failure metrics as follows:

A.B.p1.success
A.B.p3.success
A.B.p4.success
...

A.B.p1.failure
A.B.p2.failure
A.B.p4.failure
...

I have in total ~30 persons, and I want to show the each person's success rate as calculated by:

alias(asPercent(A.B.p1.success,sumSeries(A.B.p1.success,A.B.p1.failure)), 'p1')

The problem I have:

1) If I hard-code all the persons in each row, it exceeds the max row Grafana allowed, andd I want to plot them on the same graph

2) If there a way I can do it by a Grafana function?

Thanks in advance!

Daniel Lee
  • 7,709
  • 2
  • 48
  • 57
xpan
  • 1
  • 1
  • 1
  • 1

1 Answers1

4

The way to do this in Graphite is to use a subquery:

  1. add two queries in Grafana, query #A for the total and query #B for the success rate
  2. Hide query #A
  3. Pass query #A as a parameter into the AsPercent function in query #B

enter image description here

Use the sumSeriesWithWildcard function to sum multiple series to get the total in #A:

https://stackoverflow.com/a/12837800/22688

For more, on the AsPercent function read my blog post on this. I describe how to use the AsPercent function at the end:

https://danlimerick.wordpress.com/2017/01/29/graphite-and-grafana-how-to-calculate-percentage-of-totalpercent-distribution/

If the asPercent function does not work (depends on which version and variant of Graphite you are using), you can achieve the same result with mapSeries and reduceSeries (also in the blog post):

aliasByNode(reduceSeries(mapSeries(groupByNodes(snap.gceprod.*.intel.docker.kube-system.*.snap.stats.filesystem.*.{usage,capacity}, 'maxSeries', 2, 11), 0), 'asPercent', 1, 'usage', 'capacity'), 0)

I answered a similar question here if you need another example: https://stackoverflow.com/a/42714756/22688

Community
  • 1
  • 1
Daniel Lee
  • 7,709
  • 2
  • 48
  • 57
  • one could use reduceSeries + mapSeries with asPercent, but still as far as I understand it requires metrics with total values. OP have only successes and failures - not sum of them. – kwarunek Mar 07 '17 at 20:19
  • Maybe I don't really understand the question. Can the OP not just sum the success and failure series with the groupByNode function which the OP can do in query #A? – Daniel Lee Mar 07 '17 at 20:43
  • @kwarunek thinking about it a bit more, sumSeriesWithWildcard should do the trick to the get the total. – Daniel Lee Mar 07 '17 at 20:56
  • This is what I got: "asPercent second argument must reference exactly 1 series" if I expand the red request error shown in the upper left corner.. – xpan Mar 08 '17 at 23:26
  • @xpan I guess you didn't see in the blog post where I described doing the same thing with mapSeries and reduceSeries? Updated the answer with an example query. – Daniel Lee Mar 10 '17 at 09:21
  • @DanielLee Will take a look later at that. Thanks for the followups. – xpan Mar 17 '17 at 00:06
  • @xpan noticing that the functions work very differently between different versions of graphite so I'm not sure if you have a GroupByNodes function on your version of Graphite? – Daniel Lee Mar 17 '17 at 09:08