Skip to content

Add schema version monitoring to gitlab-exporter

Background

We need a way to monitor schema version changes in an existing monitoring tool

Proposal

Add to gitlab-exporter a new schema version metric

  • it should only run if the query from Repository.should_be_reindexed.exists? returns true
  • it should export counts for each schema version type (not sure what kind of monitor yet)

this script was copied from the monitoring in gitlab-com/gl-infra/production#20396 (closed)

def monitor_schema_versions(target_schema_version:, iterations: 1000, interval: 30)
  iterations.times do
    counts = Search::Zoekt::Repository.group(:schema_version).count
    total  = counts.values.sum
    percent = total > 0 ? (counts[target_schema_version].to_f / total * 100).round(2) : 0

    puts "#{Time.zone.now}:\t#{counts}\t#{percent}%"
    sleep interval
  end
end

Proposed query

SELECT COUNT(*) AS "count_all", "zoekt_repositories"."schema_version" AS "zoekt_repositories_schema_version" 
FROM "zoekt_repositories" 
GROUP BY "zoekt_repositories"."schema_version"

Tasks

Edited by Ravi Kumar