Make redis-exporter work with external Redis instances
What does this MR do?
This commit adds support for using redis-exporter with an external Redis instance when enabled via:
redis_exporter['enable'] = true
Omnibus GitLab disables redis-exporter if the bundled Redis instance is disabled, but previously when redis-exporter were enabled it would always attempt to talk to a local UNIX socket.
This commit has been tested with Google Memorystore with TLS enabled. Note that TLS client auth is not yet supported.
Related issues
- https://forum.gitlab.com/t/use-redis-exporter-with-external-redis-instance/58281
- https://gitlab.zendesk.com/agent/tickets/479756
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
-
MR title and description are up to date, accurate, and descriptive. -
MR targeting the appropriate branch. -
Latest Merge Result pipeline is green. -
When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.
For GitLab team members
If you don't have access to this, the reviewer should trigger these jobs for you during the review process.
-
The manual Trigger:ee-package
jobs have a green pipeline running against latest commit. -
If config/software
orconfig/patches
directories are changed, make sure thebuild-package-on-all-os
job within theTrigger:ee-package
downstream pipeline succeeded. -
If you are changing anything SSL related, then the Trigger:package:fips
manual job within theTrigger:ee-package
downstream pipeline must succeed. -
If CI configuration is changed, the branch must be pushed to dev.gitlab.org
to confirm regular branch builds aren't broken.
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes. -
Documentation created/updated. -
Tests added. -
Integration tests added to GitLab QA. -
Equivalent MR/issue for the GitLab Chart opened. -
Validate potential values for new configuration settings. Formats such as integer 10
, duration10s
, URIscheme://user:passwd@host:port
may require quotation or other special handling when rendered in a template and written to a configuration file.
Test plan
- Set up an external Redis. If using Google Memorystore, then be sure to download the server TLS certs and add them to
/etc/gitlab/trusted-certs
. - In
/etc/gitlab/gitlab.rb
, add these settings and rungitlab-ctl reconfigure
.
redis['enable'] = false
gitlab_rails['redis_host'] = "SOME-REDIS-HOST"
gitlab_rails['redis_port'] = 6379
gitlab_rails['redis_ssl'] = true
gitlab_rails['redis_password'] = "REDIS-PASSWORD"
gitlab_rails['redis_enable_client'] = false
redis['port'] = 6379
redis_exporter['enable'] = true
- Run
gitlab-ctl tail redis-exporter
- Run
curl -s http://localhost:9121/metrics | grep redis_db_keys
. If everything is working, you should see something like:
# HELP redis_db_keys Total number of keys by DB
# TYPE redis_db_keys gauge
redis_db_keys{db="db0"} 780
redis_db_keys{db="db1"} 0
redis_db_keys{db="db10"} 0
redis_db_keys{db="db11"} 0
redis_db_keys{db="db12"} 0
redis_db_keys{db="db13"} 0
redis_db_keys{db="db14"} 0
redis_db_keys{db="db15"} 0
redis_db_keys{db="db2"} 0
redis_db_keys{db="db3"} 0
redis_db_keys{db="db4"} 0
redis_db_keys{db="db5"} 0
redis_db_keys{db="db6"} 0
redis_db_keys{db="db7"} 0
redis_db_keys{db="db8"} 0
redis_db_keys{db="db9"} 0
# HELP redis_db_keys_expiring Total number of expiring keys by DB
# TYPE redis_db_keys_expiring gauge
redis_db_keys_expiring{db="db0"} 345
redis_db_keys_expiring{db="db1"} 0
redis_db_keys_expiring{db="db10"} 0
redis_db_keys_expiring{db="db11"} 0
redis_db_keys_expiring{db="db12"} 0
redis_db_keys_expiring{db="db13"} 0
redis_db_keys_expiring{db="db14"} 0
redis_db_keys_expiring{db="db15"} 0
redis_db_keys_expiring{db="db2"} 0
redis_db_keys_expiring{db="db3"} 0
redis_db_keys_expiring{db="db4"} 0
redis_db_keys_expiring{db="db5"} 0
redis_db_keys_expiring{db="db6"} 0
redis_db_keys_expiring{db="db7"} 0
redis_db_keys_expiring{db="db8"} 0
redis_db_keys_expiring{db="db9"} 0
Edited by Stan Hu