Count rows by userName label

Using the following metric query in Grafana (as a Time Seres)

count_values("build",jenkins_job_last_build{project="$project",jobname="$jobname"}) by (userName)

Produces the following Result set for me:

UserName 	                Count
{build="1364",userName="Fred"}	75
{build="1360",userName="Fred"}	2
{build="1357",userName="Fred"}	1
{build="1353",userName="BIll"}	5
{build="1352",userName="BIll"}	2

However I’m trying to produce a table that shows the number of builds for each user such that I would have:

UserName      Count

Fred          3
BIll          2

I’ve tried playing with the “Tables series aggregations” and wrapping sum, count, count_values around the query above but no luck so far.
Could anyone give me any pointers please?

Thanks,
Ed

Not sure how prometheus function count_values works, best best is to check prometheus docs for this function or ask in prometheus mailing list or IRC channel

1 Like