Commit 1ba281b0 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Merge branch...

Merge branch '29716-prometheus-server-fails-to-get-metrics-from-deployed-environments' into 'master'

Rake task to ensure metrics from deployed environments

Closes #29716

See merge request gitlab-org/gitlab!21007
parents 5e72c2d2 1802a271
...@@ -270,3 +270,15 @@ database: gitlabhq_production ...@@ -270,3 +270,15 @@ database: gitlabhq_production
-------------------------------------------------- --------------------------------------------------
up migration_id migration_name up migration_id migration_name
``` ```
## Import common metrics
Sometimes you may need to re-import the common metrics that power the Metrics dashboards.
This could be as a result of [updating existing metrics](../../development/prometheus_metrics.md#update-existing-metrics), or as a [troubleshooting measure](../../user/project/integrations/prometheus.md#troubleshooting).
To re-import the metrics you can run:
```sh
sudo gitlab-rake metrics:setup_common_metrics
```
...@@ -22,7 +22,9 @@ The requirement for adding a new metric is to make each query to have an unique ...@@ -22,7 +22,9 @@ The requirement for adding a new metric is to make each query to have an unique
### Update existing metrics ### Update existing metrics
After you add or change existing _common_ metric you have to create a new database migration that will query and update all existing metrics. After you add or change an existing common metric, you must [re-run the import script](../administration/raketasks/maintenance.md#import-common-metrics) that will query and update all existing metrics.
Or, you can create a database migration:
NOTE: **Note:** NOTE: **Note:**
If a query metric (which is identified by `id:`) is removed it will not be removed from database by default. If a query metric (which is identified by `id:`) is removed it will not be removed from database by default.
......
...@@ -574,6 +574,7 @@ If the "No data found" screen continues to appear, it could be due to: ...@@ -574,6 +574,7 @@ If the "No data found" screen continues to appear, it could be due to:
are not labeled correctly. To test this, connect to the Prometheus server and are not labeled correctly. To test this, connect to the Prometheus server and
[run a query](prometheus_library/kubernetes.html#metrics-supported), replacing `$CI_ENVIRONMENT_SLUG` [run a query](prometheus_library/kubernetes.html#metrics-supported), replacing `$CI_ENVIRONMENT_SLUG`
with the name of your environment. with the name of your environment.
- You may need to re-add the GitLab predefined common metrics. This can be done by running the [import common metrics rake task](../../../administration/raketasks/maintenance.md#import-common-metrics).
[autodeploy]: ../../../topics/autodevops/index.md#auto-deploy [autodeploy]: ../../../topics/autodevops/index.md#auto-deploy
[kubernetes]: https://kubernetes.io [kubernetes]: https://kubernetes.io
......
# frozen_string_literal: true
namespace :metrics do
desc "GitLab | Setup common metrics"
task setup_common_metrics: :gitlab_environment do
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment