Skip to content

Sample database metrics for replica hosts

Patrick Bair requested to merge 346909-sample-host-metrics-for-db-replicas into master

What does this MR do and why?

In !75793 (merged), we updated the database host metrics to include all connection classes, defined in Gitlab::Database.base_database_models, not just ActiveRecord::Base.

As a follow up to that, this MR extends the metrics collection to include statistics for replica hosts if any are configured.

Related to #346909 (closed)

How to set up and validate locally

  1. You can collect the metrics for your configured database hosts by executing the following in the rails console:
    sampler = Gitlab::Metrics::Samplers::DatabaseSampler.new
    sampler.sample
    The method will return an array containing a hash of the labels and stats for each host.
  2. You can then view and inspect the Prometheus metrics by running:
    sampler.metrics

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Patrick Bair

Merge request reports