Add Grafana to Admin > Monitoring menu when enabled

This commit is contained in:
Maneschi Romain 2019-07-03 16:09:51 +00:00 committed by Rémy Coutable
parent 6359a1fabd
commit def94f5043
11 changed files with 113 additions and 0 deletions

View File

@ -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,

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
---
title: Adds link to Grafana in Admin > Monitoring settings when grafana is enabled in config
merge_request: 28937
author: Romain Maneschi
type: added

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class AddGrafanaToSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default(:application_settings, :grafana_enabled, :boolean,
default: false, allow_null: false)
end
def down
remove_column(:application_settings, :grafana_enabled)
end
end

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class AddGrafanaUrlToSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default(:application_settings, :grafana_url, :string,
default: '/-/grafana', allow_null: false)
end
def down
remove_column(:application_settings, :grafana_url)
end
end

View File

@ -193,6 +193,7 @@ ActiveRecord::Schema.define(version: 20190628185004) do
t.string "required_instance_ci_template"
t.boolean "dns_rebinding_protection_enabled", default: true, null: false
t.boolean "default_project_deletion_protection", default: false, null: false
t.boolean "grafana_enabled", default: false, null: false
t.boolean "lock_memberships_to_ldap", default: false, null: false
t.text "help_text"
t.boolean "elasticsearch_indexing", default: false, null: false
@ -226,6 +227,7 @@ ActiveRecord::Schema.define(version: 20190628185004) do
t.boolean "elasticsearch_limit_indexing", default: false, null: false
t.string "geo_node_allowed_ips", default: "0.0.0.0/0, ::/0"
t.boolean "time_tracking_limit_to_hours", default: false, null: false
t.string "grafana_url", default: "/-/grafana", null: false
t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id", using: :btree
t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id", using: :btree
t.index ["usage_stats_set_by_user_id"], name: "index_application_settings_on_usage_stats_set_by_user_id", using: :btree

View File

@ -103,6 +103,21 @@ repository for more information on this process.
[grafana-dashboards]: https://gitlab.com/gitlab-org/grafana-dashboards
## Integration with GitLab UI
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/61005) in GitLab 12.1.
If you have set up Grafana, you can enable a link to access it easily from the sidebar:
1. Go to the admin area under **Settings > Metrics and profiling**
and expand "Metrics - Grafana".
1. Check the "Enable access to Grafana" checkbox.
1. If Grafana is enabled through Omnibus GitLab and on the same server,
leave "Grafana URL" unchanged. In any other case, enter the full URL
path of the Grafana instance.
1. Click **Save changes**.
1. The new link will be available in the admin area under **Monitoring > Metrics Dashboard**.
---
Read more on:

View File

@ -55,6 +55,8 @@ module API
optional :gitaly_timeout_default, type: Integer, desc: 'Default Gitaly timeout, in seconds. Set to 0 to disable timeouts.'
optional :gitaly_timeout_fast, type: Integer, desc: 'Gitaly fast operation timeout, in seconds. Set to 0 to disable timeouts.'
optional :gitaly_timeout_medium, type: Integer, desc: 'Medium Gitaly timeout, in seconds. Set to 0 to disable timeouts.'
optional :grafana_enabled, type: Boolean, desc: 'Enable Grafana'
optional :grafana_url, type: String, desc: 'Grafana URL'
optional :gravatar_enabled, type: Boolean, desc: 'Flag indicating if the Gravatar service is enabled'
optional :help_page_hide_commercial_content, type: Boolean, desc: 'Hide marketing-related entries from help'
optional :help_page_support_url, type: String, desc: 'Alternate support URL for help page'

View File

@ -605,6 +605,9 @@ msgstr ""
msgid "Add a GPG key"
msgstr ""
msgid "Add a Grafana button in the admin sidebar, monitoring section, to access a variety of statistics on the health and performance of GitLab."
msgstr ""
msgid "Add a bullet list"
msgstr ""
@ -3923,9 +3926,15 @@ msgstr ""
msgid "Enable HTML emails"
msgstr ""
msgid "Enable access to Grafana"
msgstr ""
msgid "Enable access to the Performance Bar for a given group."
msgstr ""
msgid "Enable and configure Grafana."
msgstr ""
msgid "Enable and configure InfluxDB metrics."
msgstr ""
@ -4933,6 +4942,9 @@ msgstr ""
msgid "Got it!"
msgstr ""
msgid "Grafana URL"
msgstr ""
msgid "Grant access"
msgstr ""
@ -6391,12 +6403,18 @@ msgstr ""
msgid "Metrics"
msgstr ""
msgid "Metrics - Grafana"
msgstr ""
msgid "Metrics - Influx"
msgstr ""
msgid "Metrics - Prometheus"
msgstr ""
msgid "Metrics Dashboard"
msgstr ""
msgid "Metrics and profiling"
msgstr ""