Configure Grafana only once
This change adds grafana dashboards and datasource only on the primary node. Implements: blueprint influxdb-clustering Change-Id: I5eb93ee01ab8fc6e4bb6d3ad88299293ac1cd85d
This commit is contained in:
parent
a876bbc80e
commit
8bf667b4ae
@ -24,9 +24,6 @@ $db_password = $influxdb_grafana['mysql_password']
|
|||||||
|
|
||||||
$admin_username = $influxdb_grafana['grafana_username']
|
$admin_username = $influxdb_grafana['grafana_username']
|
||||||
$admin_password = $influxdb_grafana['grafana_userpass']
|
$admin_password = $influxdb_grafana['grafana_userpass']
|
||||||
$influxdb_username = $influxdb_grafana['influxdb_username']
|
|
||||||
$influxdb_password = $influxdb_grafana['influxdb_userpass']
|
|
||||||
$influxdb_database = $influxdb_grafana['influxdb_dbname']
|
|
||||||
|
|
||||||
case $db_mode {
|
case $db_mode {
|
||||||
|
|
||||||
@ -54,34 +51,26 @@ host=<%= @db_vip %>
|
|||||||
host => $db_vip,
|
host => $db_vip,
|
||||||
} ->
|
} ->
|
||||||
class {'lma_monitoring_analytics::grafana':
|
class {'lma_monitoring_analytics::grafana':
|
||||||
db_host => "${db_vip}:${db_port}",
|
db_host => "${db_vip}:${db_port}",
|
||||||
db_name => $db_name,
|
db_name => $db_name,
|
||||||
db_username => $db_username,
|
db_username => $db_username,
|
||||||
db_password => $db_password,
|
db_password => $db_password,
|
||||||
admin_username => $admin_username,
|
admin_username => $admin_username,
|
||||||
admin_password => $admin_password,
|
admin_password => $admin_password,
|
||||||
influxdb_url => "http://${mgmt_vip}:8086",
|
domain => $mgmt_vip,
|
||||||
influxdb_username => $influxdb_username,
|
|
||||||
influxdb_password => $influxdb_password,
|
|
||||||
influxdb_database => $influxdb_database,
|
|
||||||
domain => $mgmt_vip,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
'remote': {
|
'remote': {
|
||||||
# In this case we suppose that database has been created.
|
# In this case we suppose that database has been created.
|
||||||
class {'lma_monitoring_analytics::grafana':
|
class {'lma_monitoring_analytics::grafana':
|
||||||
db_host => $influxdb_grafana['mysql_host'],
|
db_host => $influxdb_grafana['mysql_host'],
|
||||||
db_name => $db_name,
|
db_name => $db_name,
|
||||||
db_username => $db_username,
|
db_username => $db_username,
|
||||||
db_password => $db_password,
|
db_password => $db_password,
|
||||||
admin_username => $admin_username,
|
admin_username => $admin_username,
|
||||||
admin_password => $admin_password,
|
admin_password => $admin_password,
|
||||||
influxdb_url => "http://${mgmt_vip}:8086",
|
domain => $mgmt_vip,
|
||||||
influxdb_username => $influxdb_username,
|
|
||||||
influxdb_password => $influxdb_password,
|
|
||||||
influxdb_database => $influxdb_dbname,
|
|
||||||
domain => $mgmt_vip,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
41
deployment_scripts/puppet/manifests/grafana_configuration.pp
Normal file
41
deployment_scripts/puppet/manifests/grafana_configuration.pp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Copyright 2016 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
$mgmt_vip = hiera('lma::influxdb::vip')
|
||||||
|
$influxdb_grafana = hiera('influxdb_grafana')
|
||||||
|
|
||||||
|
$admin_username = $influxdb_grafana['grafana_username']
|
||||||
|
$admin_password = $influxdb_grafana['grafana_userpass']
|
||||||
|
$influxdb_username = $influxdb_grafana['influxdb_username']
|
||||||
|
$influxdb_password = $influxdb_grafana['influxdb_userpass']
|
||||||
|
$influxdb_database = $influxdb_grafana['influxdb_dbname']
|
||||||
|
|
||||||
|
grafana_datasource { 'lma':
|
||||||
|
ensure => present,
|
||||||
|
url => "http://${mgmt_vip}:8086",
|
||||||
|
user => $influxdb_username,
|
||||||
|
password => $influxdb_password,
|
||||||
|
database => $influxdb_database,
|
||||||
|
access_mode => 'proxy',
|
||||||
|
is_default => true,
|
||||||
|
grafana_url => "http://${mgmt_vip}:8000",
|
||||||
|
grafana_user => $admin_username,
|
||||||
|
grafana_password => $admin_password,
|
||||||
|
}
|
||||||
|
|
||||||
|
class {'lma_monitoring_analytics::grafana_dashboards':
|
||||||
|
admin_username => $admin_username,
|
||||||
|
admin_password => $admin_password,
|
||||||
|
host => $mgmt_vip,
|
||||||
|
}
|
@ -23,10 +23,6 @@ class lma_monitoring_analytics::grafana (
|
|||||||
$admin_password = undef,
|
$admin_password = undef,
|
||||||
$domain = $lma_monitoring_analytics::params::grafana_domain,
|
$domain = $lma_monitoring_analytics::params::grafana_domain,
|
||||||
$http_port = $lma_monitoring_analytics::params::listen_port,
|
$http_port = $lma_monitoring_analytics::params::listen_port,
|
||||||
$influxdb_url = $lma_monitoring_analytics::params::influxdb_url,
|
|
||||||
$influxdb_username = undef,
|
|
||||||
$influxdb_password = undef,
|
|
||||||
$influxdb_database = undef,
|
|
||||||
) inherits lma_monitoring_analytics::params {
|
) inherits lma_monitoring_analytics::params {
|
||||||
|
|
||||||
validate_string($db_host)
|
validate_string($db_host)
|
||||||
@ -67,85 +63,4 @@ class lma_monitoring_analytics::grafana (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
grafana_datasource { 'influxdb':
|
|
||||||
ensure => present,
|
|
||||||
url => $influxdb_url,
|
|
||||||
user => $influxdb_username,
|
|
||||||
password => $influxdb_password,
|
|
||||||
database => $influxdb_database,
|
|
||||||
access_mode => 'proxy',
|
|
||||||
is_default => true,
|
|
||||||
grafana_url => "http://${domain}:${http_port}",
|
|
||||||
grafana_user => $admin_username,
|
|
||||||
grafana_password => $admin_password,
|
|
||||||
require => Class['::grafana'],
|
|
||||||
}
|
|
||||||
|
|
||||||
$dashboard_defaults = {
|
|
||||||
ensure => present,
|
|
||||||
grafana_url => "http://${domain}:${http_port}",
|
|
||||||
grafana_user => $admin_username,
|
|
||||||
grafana_password => $admin_password,
|
|
||||||
require => Class['::grafana'],
|
|
||||||
}
|
|
||||||
|
|
||||||
$dashboards = {
|
|
||||||
'Main' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Main.json'),
|
|
||||||
},
|
|
||||||
'System' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/System.json'),
|
|
||||||
},
|
|
||||||
'LMA self-monitoring' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/LMA.json'),
|
|
||||||
},
|
|
||||||
'Apache' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Apache.json'),
|
|
||||||
},
|
|
||||||
'Cinder' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Cinder.json'),
|
|
||||||
},
|
|
||||||
'Glance' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Glance.json'),
|
|
||||||
},
|
|
||||||
'HAProxy' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/HAProxy.json'),
|
|
||||||
},
|
|
||||||
'Heat' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Heat.json'),
|
|
||||||
},
|
|
||||||
'Libvirt' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Libvirt.json'),
|
|
||||||
},
|
|
||||||
'Keystone' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Keystone.json'),
|
|
||||||
},
|
|
||||||
'Memcached' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Memcached.json'),
|
|
||||||
},
|
|
||||||
'MySQL' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/MySQL.json'),
|
|
||||||
},
|
|
||||||
'Memcached' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Memcached.json'),
|
|
||||||
},
|
|
||||||
'Neutron' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Neutron.json'),
|
|
||||||
},
|
|
||||||
'Nova' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Nova.json'),
|
|
||||||
},
|
|
||||||
'RabbitMQ' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/RabbitMQ.json'),
|
|
||||||
},
|
|
||||||
'Ceph' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Ceph.json'),
|
|
||||||
},
|
|
||||||
'Ceph OSD' => {
|
|
||||||
content => template('lma_monitoring_analytics/grafana_dashboards/Ceph_OSD.json'),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
create_resources(grafana_dashboard, $dashboards, $dashboard_defaults)
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
# Copyright 2016 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
# == Class: lma_monitoring_analytics::grafana_dashboards
|
||||||
|
|
||||||
|
class lma_monitoring_analytics::grafana_dashboards (
|
||||||
|
$admin_username,
|
||||||
|
$admin_password,
|
||||||
|
$host = $lma_monitoring_analytics::params::grafana_domain,
|
||||||
|
$port = $lma_monitoring_analytics::params::listen_port,
|
||||||
|
) inherits lma_monitoring_analytics::params {
|
||||||
|
|
||||||
|
$dashboard_defaults = {
|
||||||
|
ensure => present,
|
||||||
|
grafana_url => "http://${host}:${port}",
|
||||||
|
grafana_user => $admin_username,
|
||||||
|
grafana_password => $admin_password,
|
||||||
|
}
|
||||||
|
|
||||||
|
$dashboards = {
|
||||||
|
'Main' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Main.json'),
|
||||||
|
},
|
||||||
|
'System' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/System.json'),
|
||||||
|
},
|
||||||
|
'LMA self-monitoring' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/LMA.json'),
|
||||||
|
},
|
||||||
|
'Apache' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Apache.json'),
|
||||||
|
},
|
||||||
|
'Cinder' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Cinder.json'),
|
||||||
|
},
|
||||||
|
'Glance' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Glance.json'),
|
||||||
|
},
|
||||||
|
'HAProxy' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/HAProxy.json'),
|
||||||
|
},
|
||||||
|
'Heat' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Heat.json'),
|
||||||
|
},
|
||||||
|
'Libvirt' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Libvirt.json'),
|
||||||
|
},
|
||||||
|
'Keystone' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Keystone.json'),
|
||||||
|
},
|
||||||
|
'Memcached' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Memcached.json'),
|
||||||
|
},
|
||||||
|
'MySQL' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/MySQL.json'),
|
||||||
|
},
|
||||||
|
'Memcached' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Memcached.json'),
|
||||||
|
},
|
||||||
|
'Neutron' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Neutron.json'),
|
||||||
|
},
|
||||||
|
'Nova' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Nova.json'),
|
||||||
|
},
|
||||||
|
'RabbitMQ' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/RabbitMQ.json'),
|
||||||
|
},
|
||||||
|
'Ceph' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Ceph.json'),
|
||||||
|
},
|
||||||
|
'Ceph OSD' => {
|
||||||
|
content => template('lma_monitoring_analytics/grafana_dashboards/Ceph_OSD.json'),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
create_resources(grafana_dashboard, $dashboards, $dashboard_defaults)
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
# Copyright 2015 Mirantis, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'lma_monitoring_analytics::grafana_dashboards', :type => :class do
|
||||||
|
let(:facts) do
|
||||||
|
{:kernel => 'Linux', :operatingsystem => 'Ubuntu', :osfamily => 'Debian'}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'with defaults' do
|
||||||
|
let (:params) do {:admin_username => 'admin', :admin_password => 'pass'} end
|
||||||
|
it { is_expected.to contain_grafana_dashboard('Main') }
|
||||||
|
end
|
||||||
|
end
|
@ -28,8 +28,6 @@ describe 'lma_monitoring_analytics::grafana', :type => :class do
|
|||||||
it { is_expected.to contain_package('grafana').with(
|
it { is_expected.to contain_package('grafana').with(
|
||||||
:ensure => 'latest'
|
:ensure => 'latest'
|
||||||
)}
|
)}
|
||||||
it { is_expected.to contain_grafana_datasource('influxdb') }
|
|
||||||
it { is_expected.to contain_grafana_dashboard('Main') }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'db_host without port number' do
|
describe 'db_host without port number' do
|
||||||
@ -42,7 +40,5 @@ describe 'lma_monitoring_analytics::grafana', :type => :class do
|
|||||||
it { is_expected.to contain_package('grafana').with(
|
it { is_expected.to contain_package('grafana').with(
|
||||||
:ensure => 'latest'
|
:ensure => 'latest'
|
||||||
)}
|
)}
|
||||||
it { is_expected.to contain_grafana_datasource('influxdb') }
|
|
||||||
it { is_expected.to contain_grafana_dashboard('Main') }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,3 +25,11 @@
|
|||||||
puppet_manifest: puppet/manifests/influxdb_configuration.pp
|
puppet_manifest: puppet/manifests/influxdb_configuration.pp
|
||||||
puppet_modules: puppet/modules
|
puppet_modules: puppet/modules
|
||||||
timeout: 600
|
timeout: 600
|
||||||
|
|
||||||
|
- role: ['primary-influxdb_grafana']
|
||||||
|
stage: post_deployment/8100
|
||||||
|
type: puppet
|
||||||
|
parameters:
|
||||||
|
puppet_manifest: puppet/manifests/grafana_configuration.pp
|
||||||
|
puppet_modules: puppet/modules
|
||||||
|
timeout: 600
|
||||||
|
Loading…
Reference in New Issue
Block a user