简体   繁体   中英

how to plot percentage on grafana?

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!

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

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM