Skip to content

Allow discovering Prometheus from Consul for Topology Ping

What does this MR do?

Allow discovering Prometheus service API URI from Consul for Topology Ping

The issue to solve:

Previously we rely on Prometheus settings(in config/gitlab.yml), and use Gitlab::Prometheus::Internal.uri to get Prometheus service address/port. This works majorly for single-node Gitlab instance.

For multi-node GitLab instance, the user setup the Prometheus server on a different node rather than on the same node as Sidekiq(we especially care Sidekiq node because topology usage ping runs from Sidekiq). In this case, there are two possibilities:

  • the user provides prometheus_server_address(a new setting introduced by #30175 (closed)). Then it will still work.
  • the user did not provide prometheus_server_address. It will not get the Prometheus server address.

The concern is: prometheus_server_address setting was introduced recently, so it won't be available for those users who did not get a chance to upgrade to the newest GitLab version.

Solution

Consul has already been available for EEP users for quite a while. Consul service discovery is another source we can get Prometheus service address.

This MR get the Prometheus service address from the Consul service discovery, in the situation of:

  • when the Prometheus address is not available from the gitlab.yml setting. In terms of code, it translates to Gitlab::Prometheus::Internal.prometheus_enabled? == false. AND,
  • consul is available(consul['api_url'] present)

This MR depends on omnibus-gitlab!4482 (merged), where Consul api_url is exposed to config/gitlab.yml.

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #222343 (closed)

Edited by Qingyu Zhao

Merge request reports