Skip to content

monitor gitlab issues counts in prometheus

right now i manually write down the number of issues that are open/closed/Icebox/Backlog/Next/Doing in each monthly report. that's kind of ridiculous because it takes time every month, but also limited because we don't get historical data. in september 2021, i did a somewhat detailed analysis of the month-per-month metrics, which give a good idea of the data we could render.

basically, i think we want to define a set of (gitlab) labels and then put in prometheus the number of tickets that match one of those labels (or none, or closed), and per project. so this report from september:

  • open: 0
  • icebox: 119
  • backlog: 17
  • next: 6
  • doing: 5
  • needs information: 3
  • needs review: 0
  • (closed: 2387)

would be something like this in Prometheus:

gitlab_issues{status=open,label=icebox,project=tpo/tpa/team} 119
gitlab_issues{status=open,label=backlog,project=tpo/tpa/team} 17
gitlab_issues{status=open,label=next,project=tpo/tpa/team} 6
gitlab_issues{status=open,label=doing,project=tpo/tpa/team} 5
gitlab_issues{status=open,label=needs information,project=tpo/tpa/team} 3
gitlab_issues{status=open,label=needs review,project=tpo/tpa/team} 0
gitlab_issues{status=open,project=tpo/tpa/team} 0
gitlab_issues{status=closed,project=tpo/tpa/team} 2387

alternatively, if we don't want to pre-define a list of labels, we could just pull all the labels in one metric, and open/close in another

gitlab_open_issues_per_label{label=icebox,project=tpo/tpa/team} 119
gitlab_open_issues_per_label{label=backlog,project=tpo/tpa/team} 17
gitlab_open_issues_per_label{label=next,project=tpo/tpa/team} 6
gitlab_open_issues_per_label{label=doing,project=tpo/tpa/team} 5
gitlab_open_issues_per_label{label=needs information,project=tpo/tpa/team} 3
gitlab_open_issues_per_label{label=needs review,project=tpo/tpa/team} 0
gitlab_open_issues_per_label{project=tpo/tpa/team} 0
gitlab_issues{status=closed,project=tpo/tpa/team} 2387
gitlab_issues{status=open,project=tpo/tpa/team} 150

there's this one python project that might do it, but it will probably needs to be patched. i filed a ticket upstream with gitlab to see if this was possible there as well.

Edited by anarcat
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information