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
-
add to gitlab-exportera new metric namedsearch_zoekt_schema_version_totalwith a label for eachschema_version(see metric naming guidelines) -
release new version of gitlab-exporter (example gitlab-org/ruby/gems/gitlab-exporter!244 (merged)) -
use new version of gitlab-exporter in gstg (example https://gitlab.com/gitlab-com/gl-infra/chef-repo/-/merge_requests/6034) -
use new version of gitlab-exporter in gprd (example https://gitlab.com/gitlab-com/gl-infra/chef-repo/-/merge_requests/6035)
Edited by Ravi Kumar