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.

heka.pp 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # Copyright 2016 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. #
  15. # == Define: lma_collector::heka
  16. #
  17. # The lma_collector::heka resource installs and configures heka service
  18. #
  19. # === Parameters
  20. #
  21. # === Examples
  22. #
  23. # === Authors
  24. #
  25. # Simon Pasquier <spasquier@mirantis.com>
  26. # Swann Croiset <scroiset@mirantis.com>
  27. #
  28. # === Copyright
  29. #
  30. # Copyright 2016 Mirantis Inc., unless otherwise noted.
  31. #
  32. define lma_collector::heka (
  33. $user = 'heka',
  34. $groups = [],
  35. $heka_monitoring = true,
  36. $poolsize = 100,
  37. $install_init_script = true,
  38. $version = 'latest',
  39. ) {
  40. include lma_collector::params
  41. validate_array($groups)
  42. validate_bool($heka_monitoring)
  43. validate_integer($poolsize)
  44. if ! member(['log_collector', 'metric_collector'], $title){
  45. fail('lma_collector::heka title must be either "log_collector" or "metric_collector"')
  46. }
  47. $lua_modules_dir = $lma_collector::params::lua_modules_dir
  48. $additional_groups = $user ? {
  49. 'root' => [],
  50. default => union($lma_collector::params::groups, $groups),
  51. }
  52. if $title == 'metric_collector' {
  53. $config_dir = $lma_collector::params::metric_config_dir
  54. $service_class = 'lma_collector::service::metric'
  55. $dashboard_port = $lma_collector::params::metric_dashboard_port
  56. heka::decoder::sandbox { 'metric':
  57. config_dir => $config_dir,
  58. filename => "${lma_collector::params::plugins_dir}/decoders/metric.lua",
  59. module_directory => $lua_modules_dir,
  60. config => {
  61. 'deserialize_bulk_metric_for_loggers' => 'aggregated_http_metrics_filter hdd_errors_counter_filter log_counter_filter'},
  62. notify => Class[$service_class],
  63. }
  64. heka::input::tcp { 'metric':
  65. config_dir => $config_dir,
  66. address => $lma_collector::params::metric_input_address,
  67. port => $lma_collector::params::metric_input_port,
  68. decoder => 'metric',
  69. require => [::Heka[$title], Heka::Decoder::Sandbox['metric']],
  70. notify => Class[$service_class],
  71. }
  72. } elsif $title == 'log_collector' {
  73. $config_dir = $lma_collector::params::log_config_dir
  74. $service_class = 'lma_collector::service::log'
  75. $dashboard_port = $lma_collector::params::log_dashboard_port
  76. heka::output::tcp { 'metric':
  77. config_dir => $config_dir,
  78. address => $lma_collector::params::metric_input_address,
  79. port => $lma_collector::params::metric_input_port,
  80. message_matcher => '(Type == \'metric\' || Type == \'heka.sandbox.metric\' || Type == \'heka.sandbox.bulk_metric\')',
  81. max_buffer_size => $lma_collector::params::buffering_max_buffer_log_metric_size,
  82. max_file_size => $lma_collector::params::buffering_max_file_log_metric_size,
  83. queue_full_action => $lma_collector::params::queue_full_action_log_metric,
  84. require => ::Heka[$title],
  85. notify => Class[$service_class],
  86. }
  87. }
  88. ::heka { $title:
  89. config_dir => $config_dir,
  90. user => $user,
  91. additional_groups => $additional_groups,
  92. hostname => $::hostname,
  93. max_message_size => $lma_collector::params::hekad_max_message_size,
  94. max_process_inject => $lma_collector::params::hekad_max_process_inject,
  95. max_timer_inject => $lma_collector::params::hekad_max_timer_inject,
  96. poolsize => $poolsize,
  97. install_init_script => $install_init_script,
  98. version => $version,
  99. }
  100. # Heka self-monitoring
  101. if $heka_monitoring {
  102. $heka_monitoring_ensure = present
  103. } else {
  104. $heka_monitoring_ensure = absent
  105. }
  106. if $heka_monitoring {
  107. heka::filter::sandbox { "heka_monitoring_${title}":
  108. ensure => $heka_monitoring_ensure,
  109. config_dir => $config_dir,
  110. filename => "${lma_collector::params::plugins_dir}/filters/heka_monitoring.lua",
  111. message_matcher => "Type == 'heka.all-report'",
  112. require => ::Heka[$title],
  113. module_directory => $lua_modules_dir,
  114. notify => Class[$service_class],
  115. }
  116. # Dashboard is required to enable monitoring messages
  117. heka::output::dashboard { "dashboard_${title}":
  118. config_dir => $config_dir,
  119. dashboard_address => $lma_collector::params::dashboard_address,
  120. dashboard_port => $dashboard_port,
  121. require => ::Heka[$title],
  122. notify => Class[$service_class],
  123. }
  124. }
  125. }