Identify usage of template files

Hi everyone,

we generated a lot of internal templates which others can include in their CI/CD pipelines. We wonder now if there is a way to see how often a template-pipeline is included in other projects. Ideally we would make some stats around this to see the adoption of certain templates.
Any ideas how to do this are welcome :slight_smile:

Thanks
Christian

1 Like

Hi @ChrisRu82 and welcome to our forums!

Since our CI templates API doesn’t contain any data on usage, searching the logs for calls to the template files and aggregating those numbers might help.

Hi @katrinleinweber. And thanks for this. Any suggestions which log is the best one to do it? Also is there any documentation how this is logged in detail. Then I can dig into this.
Thanks in advance
Christian

Hi @ChrisRu82,

I tested it just now with GitLab 13.5.1-ee and find that the template name (filename without extension) will show up in:

  • nginx/gitlab_access.log: `…GET /…namespace…/…project…/templates/issue/…template…name HTTP/2.0" 200 …bytes… “https://…instance…/…namespace…/…project…/-/issues/new”…
  • gitlab-workhorse/current: {"content_type":"application/…format…"uri":"/…namespace…/…project…/templates/issue/…template…name…

The latter is probably a better start, because we have collected some examples of parsing our JSON logs with jq already.

Please do share your solution here. We’d be happy to highlight it as a tutorial :slight_smile: