Fuel plugin to collect Logging Monitoring and Alerting metrics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

controller.pp 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. # Copyright 2015 Mirantis, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. notice('fuel-plugin-lma-collector: controller.pp')
  15. $ceilometer = hiera_hash('ceilometer', {})
  16. $lma_collector = hiera_hash('lma_collector')
  17. $rabbit = hiera_hash('rabbit')
  18. $storage_options = hiera_hash('storage', {})
  19. $murano = hiera_hash('murano')
  20. $sahara = hiera_hash('sahara')
  21. if $ceilometer['enabled'] {
  22. $notification_topics = ['notifications', 'lma_notifications']
  23. }
  24. else {
  25. $notification_topics = ['lma_notifications']
  26. }
  27. # Make sure the Log and Metric collector services are configured with the
  28. # "pacemaker" provider
  29. Service<| title == 'log_collector' |> {
  30. provider => 'pacemaker'
  31. }
  32. Service<| title == 'metric_collector' |> {
  33. provider => 'pacemaker'
  34. }
  35. # OpenStack logs and notifications are useful for deriving metrics, so we enable
  36. # them even if Elasticsearch is disabled.
  37. if hiera('lma::collector::elasticsearch::server', false) or hiera('lma::collector::influxdb::server', false){
  38. # Sahara notifications
  39. if $sahara['enabled'] {
  40. include sahara::params
  41. $sahara_api_service = $::sahara::params::api_service_name
  42. $sahara_engine_service = $::sahara::params::engine_service_name
  43. sahara_config { 'DEFAULT/enable_notifications':
  44. value => true,
  45. notify => Service[$sahara_api_service, $sahara_engine_service],
  46. }
  47. sahara_config { 'DEFAULT/notification_topics':
  48. value => $notification_topics,
  49. notify => Service[$sahara_api_service, $sahara_engine_service],
  50. }
  51. sahara_config { 'DEFAULT/notification_driver':
  52. value => 'messaging',
  53. notify => Service[$sahara_api_service, $sahara_engine_service],
  54. }
  55. service { [$sahara_api_service, $sahara_engine_service]:
  56. hasstatus => true,
  57. hasrestart => true,
  58. }
  59. }
  60. # Nova notifications
  61. include nova::params
  62. $nova_api_service = $::nova::params::api_service_name
  63. $nova_conductor_service = $::nova::params::conductor_service_name
  64. $nova_scheduler_service = $::nova::params::scheduler_service_name
  65. nova_config { 'DEFAULT/notification_topics':
  66. value => $notification_topics,
  67. notify => Service[$nova_api_service, $nova_conductor_service, $nova_scheduler_service],
  68. }
  69. nova_config { 'DEFAULT/notification_driver':
  70. value => 'messaging',
  71. notify => Service[$nova_api_service, $nova_conductor_service, $nova_scheduler_service],
  72. }
  73. nova_config { 'DEFAULT/notify_on_state_change':
  74. value => 'vm_and_task_state',
  75. notify => Service[$nova_api_service, $nova_conductor_service, $nova_scheduler_service],
  76. }
  77. service { [$nova_api_service, $nova_conductor_service, $nova_scheduler_service]:
  78. hasstatus => true,
  79. hasrestart => true,
  80. }
  81. # Cinder notifications
  82. include cinder::params
  83. $cinder_api_service = $::cinder::params::api_service
  84. $cinder_scheduler_service = $::cinder::params::scheduler_service
  85. $cinder_volume_service = $::cinder::params::volume_service
  86. if $storage_options['volumes_ceph'] {
  87. # In this case, cinder-volume runs on controller node
  88. $cinder_services = [$cinder_api_service, $cinder_scheduler_service, $cinder_volume_service]
  89. } else {
  90. $cinder_services = [$cinder_api_service, $cinder_scheduler_service]
  91. }
  92. cinder_config { 'DEFAULT/notification_topics':
  93. value => $notification_topics,
  94. notify => Service[$cinder_services],
  95. }
  96. cinder_config { 'DEFAULT/notification_driver':
  97. value => 'messaging',
  98. notify => Service[$cinder_services],
  99. }
  100. service { $cinder_services:
  101. hasstatus => true,
  102. hasrestart => true,
  103. }
  104. # Keystone notifications
  105. # Keystone is executed as a WSGI application inside Apache so the Apache
  106. # service needs to be restarted if necessary
  107. include apache::params
  108. include apache::service
  109. keystone_config { 'DEFAULT/notification_topics':
  110. value => $notification_topics,
  111. notify => Class['apache::service'],
  112. }
  113. keystone_config { 'DEFAULT/notification_driver':
  114. value => 'messaging',
  115. notify => Class['apache::service'],
  116. }
  117. # Neutron notifications
  118. include neutron::params
  119. neutron_config { 'DEFAULT/notification_topics':
  120. value => $notification_topics,
  121. notify => Service[$::neutron::params::server_service],
  122. }
  123. neutron_config { 'DEFAULT/notification_driver':
  124. value => 'messaging',
  125. notify => Service[$::neutron::params::server_service],
  126. }
  127. service { $::neutron::params::server_service:
  128. hasstatus => true,
  129. hasrestart => true,
  130. }
  131. # Glance notifications
  132. include glance::params
  133. $glance_api_service = $::glance::params::api_service_name
  134. $glance_registry_service = $::glance::params::registry_service_name
  135. # Default value is 'image.localhost' for Glance
  136. $glance_publisher_id = "image.${::hostname}"
  137. glance_api_config { 'DEFAULT/notification_topics':
  138. value => $notification_topics,
  139. notify => Service[$glance_api_service],
  140. }
  141. glance_api_config { 'DEFAULT/notification_driver':
  142. value => 'messaging',
  143. notify => Service[$glance_api_service],
  144. }
  145. glance_api_config { 'DEFAULT/default_publisher_id':
  146. value => $glance_publisher_id,
  147. notify => Service[$glance_api_service],
  148. }
  149. glance_registry_config { 'DEFAULT/notification_topics':
  150. value => $notification_topics,
  151. notify => Service[$glance_registry_service],
  152. }
  153. glance_registry_config { 'DEFAULT/notification_driver':
  154. value => 'messaging',
  155. notify => Service[$glance_registry_service],
  156. }
  157. glance_registry_config { 'DEFAULT/default_publisher_id':
  158. value => $glance_publisher_id,
  159. notify => Service[$glance_registry_service],
  160. }
  161. service { [$glance_api_service, $glance_registry_service]:
  162. hasstatus => true,
  163. hasrestart => true,
  164. }
  165. # Heat notifications
  166. include heat::params
  167. $heat_api_service = $::heat::params::api_service_name
  168. $heat_engine_service = $::heat::params::engine_service_name
  169. heat_config { 'DEFAULT/notification_topics':
  170. value => $notification_topics,
  171. notify => Service[$heat_api_service, $heat_engine_service],
  172. }
  173. heat_config { 'DEFAULT/notification_driver':
  174. value => 'messaging',
  175. notify => Service[$heat_api_service, $heat_engine_service],
  176. }
  177. service { $heat_api_service:
  178. hasstatus => true,
  179. hasrestart => true,
  180. }
  181. # The heat-engine service is managed by Pacemaker.
  182. service { $heat_engine_service:
  183. hasstatus => true,
  184. hasrestart => true,
  185. provider => 'pacemaker',
  186. }
  187. lma_collector::logs::openstack { 'nova': }
  188. # For every virtual network that exists, Neutron spawns one metadata proxy
  189. # service that will log to a separate file in the Neutron log directory.
  190. # Eventually it may be hundreds of these files and Heka will have trouble
  191. # coping with the situation. See bug #1547402 for details.
  192. lma_collector::logs::openstack { 'neutron':
  193. service_match => '(dhcp-agent|l3-agent|metadata-agent|neutron-netns-cleanup|openvswitch-agent|server)',
  194. }
  195. lma_collector::logs::openstack { 'cinder': }
  196. lma_collector::logs::openstack { 'glance': }
  197. lma_collector::logs::openstack { 'heat': }
  198. lma_collector::logs::openstack { 'keystone': }
  199. class {'lma_collector::logs::keystone_wsgi': }
  200. lma_collector::logs::openstack { 'horizon': }
  201. if $murano['enabled'] {
  202. lma_collector::logs::openstack { 'murano': }
  203. }
  204. if $sahara['enabled'] {
  205. lma_collector::logs::openstack { 'sahara': }
  206. }
  207. if ! $storage_options['objects_ceph'] {
  208. class { 'lma_collector::logs::swift':
  209. file_match => 'swift-all\.log\.?(?P<Seq>\d*)$',
  210. priority => '["^Seq"]',
  211. }
  212. }
  213. class { 'lma_collector::logs::pacemaker': }
  214. }
  215. # Metrics
  216. if hiera('lma::collector::influxdb::server', false) {
  217. class { 'lma_collector::logs::counter':
  218. hostname => $::hostname,
  219. }
  220. # TODO(all): This class is still called to ensure the sandbox deletion
  221. # when upgrading the plugin. Can be removed for next release after 0.10.0.
  222. class { 'lma_collector::logs::http_metrics': }
  223. class { 'lma_collector::logs::aggregated_http_metrics': }
  224. }
  225. if hiera('lma::collector::infrastructure_alerting::server', false) {
  226. $deployment_id = hiera('deployment_id')
  227. lma_collector::gse_nagios { 'global':
  228. openstack_deployment_name => $deployment_id,
  229. server => hiera('lma::collector::infrastructure_alerting::server'),
  230. http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
  231. http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
  232. user => hiera('lma::collector::infrastructure_alerting::user'),
  233. password => hiera('lma::collector::infrastructure_alerting::password'),
  234. message_type => $lma_collector['gse_cluster_global']['output_message_type'],
  235. # Following parameter must match the lma_infrastructure_alerting::params::nagios_global_vhostname_prefix
  236. virtual_hostname => '00-global-clusters',
  237. }
  238. lma_collector::gse_nagios { 'nodes':
  239. openstack_deployment_name => $deployment_id,
  240. server => hiera('lma::collector::infrastructure_alerting::server'),
  241. http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
  242. http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
  243. user => hiera('lma::collector::infrastructure_alerting::user'),
  244. password => hiera('lma::collector::infrastructure_alerting::password'),
  245. message_type => $lma_collector['gse_cluster_node']['output_message_type'],
  246. # Following parameter must match the lma_infrastructure_alerting::params::nagios_node_vhostname_prefix
  247. virtual_hostname => '00-node-clusters',
  248. }
  249. # Purge remaining files from previous 0.10.x version
  250. $toml_metric_collector_to_purge = prefix([
  251. 'filter-afd_api_backends.toml', 'filter-afd_api_endpoints.toml',
  252. 'filter-afd_service_rabbitmq_disk.toml',
  253. 'filter-afd_service_rabbitmq_memory.toml',
  254. 'filter-afd_service_rabbitmq_queue.toml',
  255. 'filter-afd_workers.toml',
  256. 'filter-service_heartbeat.toml',
  257. 'encoder-nagios_gse_global_clusters.toml',
  258. 'encoder-nagios_gse_node_clusters.toml',
  259. 'output-nagios_gse_global_clusters.toml',
  260. 'output-nagios_gse_node_clusters.toml',
  261. ], '/etc/metric_collector/')
  262. file { $toml_metric_collector_to_purge:
  263. ensure => absent,
  264. } ->
  265. lma_collector::gse_nagios { 'services':
  266. openstack_deployment_name => $deployment_id,
  267. server => hiera('lma::collector::infrastructure_alerting::server'),
  268. http_port => hiera('lma::collector::infrastructure_alerting::http_port'),
  269. http_path => hiera('lma::collector::infrastructure_alerting::http_path'),
  270. user => hiera('lma::collector::infrastructure_alerting::user'),
  271. password => hiera('lma::collector::infrastructure_alerting::password'),
  272. message_type => $lma_collector['gse_cluster_service']['output_message_type'],
  273. # Following parameter must match the lma_infrastructure_alerting::params::nagios_node_vhostname_prefix
  274. virtual_hostname => '00-service-clusters',
  275. }
  276. }