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.
-
Docs about the Prometheus metrics: https://docs.gitlab.com/runner/monitoring/#configuration-of-the-metrics-http-server
-
Docs on using
runcommand to set--listen-addressoption: https://docs.gitlab.com/runner/commands/#run-related-commands
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 runcommand to thebin/functions-gitlab-ci-runner.shbash 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-addressis just set to:9252, any IP can access the metrics (dangerous!) so we can justcurl http://<runner ip>:9252to make sure it is up. WARNING: Cannot keep this for production, security vulnerability - Have a Prometheus server setup and change the
--listen-addressto<prometheus server ip>:9252and make sure we can see the metrics for the runners
Other related references:
- Docs on using config file to set
listen_addressfor runner: https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-global-section