diff --git a/doc/source/grafana.rst b/doc/source/grafana.rst new file mode 100644 index 0000000000..69b09be6e5 --- /dev/null +++ b/doc/source/grafana.rst @@ -0,0 +1,46 @@ +:title: Grafana + +.. _grafana: + +Grafana +####### + +Grafana is an open source, feature rich metrics dashboard and graph editor for +Graphite, InfluxDB & OpenTSDB. Openstack runs Graphite which stores all the +metrics related to Nodepool, Zuul and Jenkins (to name a few). + +At a Glance +=========== + +:Hosts: + * http://grafana.openstack.org +:Puppet: + * https://github.com/bfraser/puppet-grafana + * :file:`modules/openstack_project/manifests/grafana.pp` +:Projects: + * http://grafana.org +:Bugs: + * https://storyboard.openstack.org/#!/project/748 + +Overview +======== + +Apache is configured as a reverse proxy and there is a MySQL database +backend. + + +Sysadmin +======== + +After bringing up a Grafana node with puppet, log in and configure Grafana by +hand: + +#. Log in as the admin user. + +#. Under 'Data Sources', add a new entry with following: + + - name: OpenStack + - type: Graphite + - default: checked + - url: http://graphite.openstack.org + - access: direct diff --git a/doc/source/systems.rst b/doc/source/systems.rst index 83540a6c8f..b1c0f1f9e1 100644 --- a/doc/source/systems.rst +++ b/doc/source/systems.rst @@ -8,6 +8,7 @@ Major Systems cacti gerrit + grafana jenkins zuul jjb diff --git a/manifests/site.pp b/manifests/site.pp index e88cda2fd9..38afcc6469 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -116,6 +116,24 @@ node 'review-dev.openstack.org' { } } +# Node-OS: trusty +node 'grafana.openstack.org' { + class { 'openstack_project::server': + iptables_public_tcp_ports => [80], + sysadmins => hiera('sysadmins', []), + } + class { 'openstack_project::grafana': + admin_password => hiera('grafana_admin_password', 'XXX'), + admin_user => hiera('grafana_admin_user', 'username'), + mysql_host => hiera('grafana_mysql_host', 'localhost'), + mysql_name => hiera('grafana_mysql_name', 'XXX'), + mysql_password => hiera('grafana_mysql_password', 'XXX'), + mysql_root_password => hiera('grafana_mysql_root_password', 'XXX'), + mysql_user => hiera('grafana_mysql_user', 'username'), + secret_key => hiera('grafana_secret_key', 'XXX'), + } +} + # Node-OS: precise node 'jenkins.openstack.org' { $group = "jenkins" diff --git a/modules.env b/modules.env index b9d1e9d44d..5860fe101c 100644 --- a/modules.env +++ b/modules.env @@ -35,6 +35,7 @@ # - our intent was not to limit it's use and it should be Apache # licensed SOURCE_MODULES["https://git.openstack.org/openstack-infra/puppet-vcsrepo"]="0.0.8" +SOURCE_MODULES["https://github.com/bfraser/puppet-grafana"]="c51f03df3b41755bf3968c978d80b3fc94138652" SOURCE_MODULES["https://github.com/biemond/biemond-wildfly"]="v0.2.4" SOURCE_MODULES["https://github.com/maestrodev/puppet-wget"]="v1.6.0" SOURCE_MODULES["https://github.com/nanliu/puppet-staging"]="1.0.0" diff --git a/modules/openstack_project/manifests/grafana.pp b/modules/openstack_project/manifests/grafana.pp new file mode 100644 index 0000000000..da4e6d4b44 --- /dev/null +++ b/modules/openstack_project/manifests/grafana.pp @@ -0,0 +1,91 @@ +# == Class: openstack_project::grafana +# +# === Parameters +# [*cfg*] +# Manages the Grafana configuration file. The upstream puppet-grafana module +# documentaion: https://github.com/bfraser/puppet-grafana#cfg +# +class openstack_project::grafana ( + $mysql_password, + $mysql_root_password, + $admin_password = '', + $admin_user = 'admin', + $grafana_cfg = {}, + $mysql_host = '127.0.0.1', + $mysql_name = 'grafana', + $mysql_user = 'grafana', + $secret_key = '', + $vhost_name = $::fqdn, +) { + include apache + + $grafana_cfg_defaults = { + # NOTE(pabelanger): app_mode must be the first key! + 'app_mode' => 'production', + 'analytics' => { + 'reporting_enabled' => false, + }, + 'auth.anonymous' => { + enabled => true, + }, + 'database' => { + type => 'mysql', + host => "${mysql_host}:3306", + name => $mysql_name, + user => $mysql_user, + password => $mysql_password, + }, + 'security' => { + admin_password => $admin_password, + admin_user => $admin_user, + secret_key => $secret_key, + }, + 'server' => { + http_addr => '127.0.0.1', + http_port => 8080, + }, + 'users' => { + allow_sign_up => false, + }, + } + + $grafana_cfg_merged = merge($grafana_cfg_defaults, $grafana_cfg) + + class { 'mysql::server': + config_hash => { + 'bind_address' => $mysql_host, + 'default_engine' => 'InnoDB', + 'root_password' => $mysql_root_password, + } + } + + mysql::db { $mysql_name: + grant => ['all'], + host => $mysql_host, + password => $mysql_password, + user => $mysql_user, + require => Class['mysql::server'], + } + + class { '::grafana': + cfg => $grafana_cfg_merged, + require => Mysql::Db[$mysql_name], + } + + apache::vhost { $vhost_name: + docroot => 'MEANINGLESS ARGUMENT', + port => 80, + priority => '50', + template => 'openstack_project/grafana.vhost.erb', + } + + a2mod { 'rewrite': + ensure => present, + } + a2mod { 'proxy': + ensure => present, + } + a2mod { 'proxy_http': + ensure => present, + } +} diff --git a/modules/openstack_project/templates/grafana.vhost.erb b/modules/openstack_project/templates/grafana.vhost.erb new file mode 100644 index 0000000000..9029b1c90b --- /dev/null +++ b/modules/openstack_project/templates/grafana.vhost.erb @@ -0,0 +1,16 @@ +# ************************************ +# Managed by Puppet +# ************************************ + +NameVirtualHost <%= @vhost_name %>:<%= @port %> +:<%= @port %>> + ServerName <%= @srvname %> + + ProxyPass / http://127.0.0.1:8080/ retry=0 nocanon + ProxyPassReverse / http://127.0.0.1:8080/ + + ErrorLog /var/log/apache2/<%= @name %>_error.log + LogLevel warn + CustomLog /var/log/apache2/<%= @name %>_access.log combined + ServerSignature Off +