diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2019-01-16 10:30:29 +0100 |
---|---|---|
committer | Peter Leitzen <pleitzen@gitlab.com> | 2019-01-16 10:30:29 +0100 |
commit | 2b8100ff9b1d0e9647da15d0889553df31012ca0 (patch) | |
tree | 3baa77c5db2a32700bfa1e4d9853b0224bce774b | |
parent | 87f6f6f70519ca387c4a033174e82ee4e334d980 (diff) | |
download | gitlab-ce-docs/improve-prometheus-metrics.tar.gz |
Clarify how to update existing prometheus metricsdocs/improve-prometheus-metrics
-rw-r--r-- | doc/development/prometheus_metrics.md | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/doc/development/prometheus_metrics.md b/doc/development/prometheus_metrics.md index 0511e735843..2aff629bd8f 100644 --- a/doc/development/prometheus_metrics.md +++ b/doc/development/prometheus_metrics.md @@ -24,13 +24,24 @@ The requirement for adding a new metric is to make each query to have an unique After you add or change existing _common_ metric you have to create a new database migration that will query and update all existing metrics. +``` +bin/rails generate migration ImportCommonMetrics + + invoke active_record + create db/migrate/20190116085834_import_common_metrics.rb +``` + NOTE: **Note:** If a query metric (which is identified by `id:`) is removed it will not be removed from database by default. You might want to add additional database migration that makes a decision what to do with removed one. For example: you might be interested in migrating all dependent data to a different metric. +Replace the contents of the generated migration (`db/migrate/20190116085834_import_common_metrics.rb`) with the following: + ```ruby -class ImportCommonMetrics < ActiveRecord::Migration[4.2] +# frozen_string_literal: true + +class ImportCommonMetrics < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers require Rails.root.join('db/importers/common_metrics_importer.rb') @@ -46,3 +57,15 @@ class ImportCommonMetrics < ActiveRecord::Migration[4.2] end end ``` + +NOTE: **Note:** Make sure that the class name (`ImportCommonMetrics`) matches the migration file name (`X_import_common_metrics.rb`). + +Run the migrations and verify the changes of the `prometheus_metrics` database table: + +``` +bin/rake db:migrate + +gdk psql -d gitlabhq_development + +gitlabhq_development=# SELECT * FROM prometheus_metrics; +``` |