Allow for optionall exposing the gitlab runner metrics server for Prometheus monitoring

The GitLab runner can expose an HTTP metrics server internally if the --listen-address option is specified with the gitlab-runner run command.

What we would like to do is add the ability to specify in the Terraform variables that you want to expose the metrics to a given prometheus server (host:port for the --listen-address above).

This optional variable in the Terraform (let's call it listen_address) will then append the --listen-address <host:port> to a gitlab-runner run command during configuration.

Tasks:

  • Need to add a gitlab-runner run command to the bin/functions-gitlab-ci-runner.sh bash script. Maybe either right after here during install or (probably the better option) to add a new function for "configuring the runner" in that same bash script but then add that after gitlab-runner install but before registering the runner here
  • If the --listen-address is just set to :9252, any IP can access the metrics (dangerous!) so we can just curl http://<runner ip>:9252 to make sure it is up. WARNING: Cannot keep this for production, security vulnerability
  • Have a Prometheus server setup and change the --listen-address to <prometheus server ip>:9252 and make sure we can see the metrics for the runners

Other related references: