diff options
-rw-r--r-- | db/post_migrate/20170503004427_upate_retried_for_ci_build.rb | 29 | ||||
-rw-r--r-- | doc/ci/environments.md | 34 | ||||
-rw-r--r-- | doc/ci/img/environments_monitoring.png | bin | 0 -> 94408 bytes | |||
-rw-r--r-- | doc/ci/img/prometheus_environment_detail_with_metrics.png (renamed from doc/user/project/integrations/img/prometheus_environment_detail_with_metrics.png) | bin | 120479 -> 120479 bytes | |||
-rw-r--r-- | doc/user/admin_area/settings/usage_statistics.md | 2 | ||||
-rw-r--r-- | doc/user/project/integrations/prometheus.md | 27 | ||||
-rw-r--r-- | spec/migrations/upate_retried_for_ci_builds_spec.rb | 17 |
7 files changed, 93 insertions, 16 deletions
diff --git a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb index 9b20edeb4c3..738e46b9207 100644 --- a/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb +++ b/db/post_migrate/20170503004427_upate_retried_for_ci_build.rb @@ -8,6 +8,32 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration def up disable_statement_timeout + if Gitlab::Database.mysql? + up_mysql + else + up_postgres + end + end + + def down + end + + private + + def up_mysql + # This is a trick to overcome MySQL limitation: + # Mysql2::Error: Table 'ci_builds' is specified twice, both as a target for 'UPDATE' and as a separate source for data + # However, this leads to create a temporary table from `max(ci_builds.id)` which is slow and do full database update + execute <<-SQL.strip_heredoc + UPDATE ci_builds SET retried= + (id NOT IN ( + SELECT * FROM (SELECT MAX(ci_builds.id) FROM ci_builds GROUP BY commit_id, name) AS latest_jobs + )) + WHERE retried IS NULL + SQL + end + + def up_postgres with_temporary_partial_index do latest_id = <<-SQL.strip_heredoc SELECT MAX(ci_builds2.id) @@ -26,9 +52,6 @@ class UpateRetriedForCiBuild < ActiveRecord::Migration end end - def down - end - def with_temporary_partial_index if Gitlab::Database.postgresql? execute 'CREATE INDEX CONCURRENTLY IF NOT EXISTS index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;' diff --git a/doc/ci/environments.md b/doc/ci/environments.md index bab765d1e12..169e0fbae3d 100644 --- a/doc/ci/environments.md +++ b/doc/ci/environments.md @@ -591,6 +591,38 @@ exist, you should see something like: ![Environment groups](img/environments_dynamic_groups.png) +## Monitoring environments + +>**Notes:** +> +- For the monitor dashboard to appear, you need to: + - Have enabled the [Kubernetes integration][kube] + - Have your app deployed on Kubernetes + - Have enabled the [Prometheus integration][prom] +- With GitLab 9.2, all deployments to an environment are shown directly on the + monitoring dashboard + +If your application is deployed on Kubernetes and you have enabled Prometheus +collecting metrics, you can monitor the performance behavior of your app +through the environments. + +Once configured, GitLab will attempt to retrieve performance metrics for any +environment which has had a successful deployment. If monitoring data was +successfully retrieved, a Monitoring button will appear on the environment's +detail page. + +![Environment Detail with Metrics](img/prometheus_environment_detail_with_metrics.png) + +Clicking on the Monitoring button will display a new page, showing up to the last +8 hours of performance data. It may take a minute or two for data to appear +after initial deployment. + +All deployments to an environment are shown directly on the monitoring dashboard +which allows easy correlation between any changes in performance and a new +version of the app, all without leaving GitLab. + +![Monitoring dashboard](img/environments_monitoring.png) + ## Checkout deployments locally Since 8.13, a reference in the git repository is saved for each deployment, so @@ -632,3 +664,5 @@ Below are some links you may find interesting: [gitlab-flow]: ../workflow/gitlab_flow.md [gitlab runner]: https://docs.gitlab.com/runner/ [git-strategy]: yaml/README.md#git-strategy +[kube]: ../user/project/integrations/kubernetes.md +[prom]: ../user/project/integrations/prometheus.md diff --git a/doc/ci/img/environments_monitoring.png b/doc/ci/img/environments_monitoring.png Binary files differnew file mode 100644 index 00000000000..387b6c54b61 --- /dev/null +++ b/doc/ci/img/environments_monitoring.png diff --git a/doc/user/project/integrations/img/prometheus_environment_detail_with_metrics.png b/doc/ci/img/prometheus_environment_detail_with_metrics.png Binary files differindex 214b10624a9..214b10624a9 100644 --- a/doc/user/project/integrations/img/prometheus_environment_detail_with_metrics.png +++ b/doc/ci/img/prometheus_environment_detail_with_metrics.png diff --git a/doc/user/admin_area/settings/usage_statistics.md b/doc/user/admin_area/settings/usage_statistics.md index 375e7f08e8b..beb52dde4ab 100644 --- a/doc/user/admin_area/settings/usage_statistics.md +++ b/doc/user/admin_area/settings/usage_statistics.md @@ -9,7 +9,7 @@ All statistics are opt-out, you can disable them from the admin panel. GitLab can inform you when an update is available and the importance of it. -No information other than the GitLab version and the instance's domain name +No information other than the GitLab version and the instance's hostname (through the HTTP referer) are collected. In the **Overview** tab you can see if your GitLab version is up to date. There diff --git a/doc/user/project/integrations/prometheus.md b/doc/user/project/integrations/prometheus.md index 7aa6d070a1b..d3fb5916dc6 100644 --- a/doc/user/project/integrations/prometheus.md +++ b/doc/user/project/integrations/prometheus.md @@ -17,6 +17,7 @@ the settings page with a default template. To configure the template, see the Integration with Prometheus requires the following: 1. GitLab 9.0 or higher +1. The [Kubernetes integration must be enabled][kube] on your project 1. Your app must be deployed on [Kubernetes][] 1. Prometheus must be configured to collect Kubernetes metrics 1. Each metric must be have a label to indicate the environment @@ -159,25 +160,26 @@ The queries utilized by GitLab are shown in the following table. ## Monitoring CI/CD Environments Once configured, GitLab will attempt to retrieve performance metrics for any -environment which has had a successful deployment. If monitoring data was -successfully retrieved, a Monitoring button will appear on the environment's -detail page. +environment which has had a successful deployment. -![Environment Detail with Metrics](img/prometheus_environment_detail_with_metrics.png) +[Learn more about monitoring environments.](../../../ci/environments.md#monitoring-environments) -Clicking on the Monitoring button will display a new page, showing up to the last -8 hours of performance data. It may take a minute or two for data to appear -after initial deployment. - -## Determining performance impact of a merge +## Determining the performance impact of a merge > [Introduced][ce-10408] in GitLab 9.2. -Developers can view the performance impact of their changes within the merge request workflow. When a source branch has been deployed to an environment, a sparkline will appear showing the average memory consumption of the app. The dot indicates when the current changes were deployed, with up to 30 minutes of performance data displayed before and after. The sparkline will be updated after each commit has been deployed. +Developers can view the performance impact of their changes within the merge +request workflow. When a source branch has been deployed to an environment, a +sparkline will appear showing the average memory consumption of the app. The dot +indicates when the current changes were deployed, with up to 30 minutes of +performance data displayed before and after. The sparkline will be updated after +each commit has been deployed. -Once merged and the target branch has been redeployed, the sparkline will switch to show the new environments this revision has been deployed to. +Once merged and the target branch has been redeployed, the sparkline will switch +to show the new environments this revision has been deployed to. -Performance data will be available for the duration it is persisted on the Prometheus server. +Performance data will be available for the duration it is persisted on the +Prometheus server. ![Merge Request with Performance Impact](img/merge_request_performance.png) @@ -193,6 +195,7 @@ If the "Attempting to load performance data" screen continues to appear, it coul [autodeploy]: ../../../ci/autodeploy/index.md [kubernetes]: https://kubernetes.io +[kube]: ./kubernetes.md [prometheus-k8s-sd]: https://prometheus.io/docs/operating/configuration/#<kubernetes_sd_config> [prometheus]: https://prometheus.io [gitlab-prometheus-k8s-monitor]: ../../../administration/monitoring/prometheus/index.md#configuring-prometheus-to-monitor-kubernetes diff --git a/spec/migrations/upate_retried_for_ci_builds_spec.rb b/spec/migrations/upate_retried_for_ci_builds_spec.rb new file mode 100644 index 00000000000..5cdb8a3c7da --- /dev/null +++ b/spec/migrations/upate_retried_for_ci_builds_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20170503004427_upate_retried_for_ci_build.rb') + +describe UpateRetriedForCiBuild, truncate: true do + let(:pipeline) { create(:ci_pipeline) } + let!(:build_old) { create(:ci_build, pipeline: pipeline, name: 'test') } + let!(:build_new) { create(:ci_build, pipeline: pipeline, name: 'test') } + + before do + described_class.new.up + end + + it 'updates ci_builds.is_retried' do + expect(build_old.reload).to be_retried + expect(build_new.reload).not_to be_retried + end +end |