From def94f5043abe57f453094fa570407e5b806c48a Mon Sep 17 00:00:00 2001 From: Maneschi Romain Date: Wed, 3 Jul 2019 16:09:51 +0000 Subject: Add Grafana to Admin > Monitoring menu when enabled --- app/helpers/application_settings_helper.rb | 2 ++ app/views/admin/application_settings/_grafana.html.haml | 17 +++++++++++++++++ .../metrics_and_profiling.html.haml | 11 +++++++++++ app/views/layouts/nav/sidebar/_admin.html.haml | 5 +++++ 4 files changed, 35 insertions(+) create mode 100644 app/views/admin/application_settings/_grafana.html.haml (limited to 'app') diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index a7a4e945a99..4bf9b708401 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -187,6 +187,8 @@ module ApplicationSettingsHelper :gitaly_timeout_default, :gitaly_timeout_medium, :gitaly_timeout_fast, + :grafana_enabled, + :grafana_url, :gravatar_enabled, :hashed_storage_enabled, :help_page_hide_commercial_content, diff --git a/app/views/admin/application_settings/_grafana.html.haml b/app/views/admin/application_settings/_grafana.html.haml new file mode 100644 index 00000000000..b6e02bde895 --- /dev/null +++ b/app/views/admin/application_settings/_grafana.html.haml @@ -0,0 +1,17 @@ += form_for @application_setting, url: admin_application_settings_path(anchor: 'js-grafana-settings'), html: { class: 'fieldset-form' } do |f| + = form_errors(@application_setting) + + %fieldset + %p + = _("Add a Grafana button in the admin sidebar, monitoring section, to access a variety of statistics on the health and performance of GitLab.") + = link_to icon('question-circle'), help_page_path('administration/monitoring/performance/grafana_configuration.md') + .form-group + .form-check + = f.check_box :grafana_enabled, class: 'form-check-input' + = f.label :grafana_enabled, class: 'form-check-label' do + = _('Enable access to Grafana') + .form-group + = f.label :grafana_url, _('Grafana URL'), class: 'label-bold' + = f.text_field :grafana_url, class: 'form-control', placeholder: '/-/grafana' + + = f.submit _('Save changes'), class: "btn btn-success" diff --git a/app/views/admin/application_settings/metrics_and_profiling.html.haml b/app/views/admin/application_settings/metrics_and_profiling.html.haml index 01d61beaf53..55a48da8342 100644 --- a/app/views/admin/application_settings/metrics_and_profiling.html.haml +++ b/app/views/admin/application_settings/metrics_and_profiling.html.haml @@ -24,6 +24,17 @@ .settings-content = render 'prometheus' +%section.settings.as-grafana.no-animate#js-grafana-settings{ class: ('expanded' if expanded_by_default?) } + .settings-header + %h4 + = _('Metrics - Grafana') + %button.btn.btn-default.js-settings-toggle{ type: 'button' } + = expanded_by_default? ? _('Collapse') : _('Expand') + %p + = _('Enable and configure Grafana.') + .settings-content + = render 'grafana' + %section.settings.qa-performance-bar-settings.as-performance-bar.no-animate#js-performance-bar-settings{ class: ('expanded' if expanded_by_default?) } .settings-header %h4 diff --git a/app/views/layouts/nav/sidebar/_admin.html.haml b/app/views/layouts/nav/sidebar/_admin.html.haml index 83fe871285a..87133c7ba22 100644 --- a/app/views/layouts/nav/sidebar/_admin.html.haml +++ b/app/views/layouts/nav/sidebar/_admin.html.haml @@ -81,6 +81,11 @@ = link_to admin_requests_profiles_path, title: _('Requests Profiles') do %span = _('Requests Profiles') + - if Gitlab::CurrentSettings.current_application_settings.grafana_enabled? + = nav_link do + = link_to Gitlab::CurrentSettings.current_application_settings.grafana_url, target: '_blank', title: _('Metrics Dashboard') do + %span + = _('Metrics Dashboard') = render_if_exists 'layouts/nav/ee/admin/new_monitoring_sidebar' = nav_link(controller: :broadcast_messages) do -- cgit v1.2.3