From a22b5a9066755e804eb3b7a2020c540d2dc0c413 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 13 Sep 2016 12:42:47 -0400 Subject: [PATCH] Use MQTT output plugin on logstash workers This commit will enable the mqtt output plugin on logstash workers. So now we'll be emitting logstash events to the firehose for anyone to listen to. Change-Id: I570a461ee13f5dfa5494554df1cc321fc6cdbf6c Depends-On: I7255f6c256ab3e3ca33caf69b71bf4ffab02c1bb --- manifests/site.pp | 3 +++ .../manifests/logstash_worker.pp | 15 ++++++++++++--- .../templates/logstash/output.conf.erb | 12 ++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index 678d13a2dd..a3e40fd5aa 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -460,6 +460,9 @@ node /^logstash-worker\d+\.openstack\.org$/ { class { 'openstack_project::logstash_worker': discover_node => 'elasticsearch02.openstack.org', + enable_mqtt => true, + mqtt_password => hiera('mqtt_service_user_password'), + mqtt_ca_cert_contents => hiera('mosquitto_tls_ca_file'), } } diff --git a/modules/openstack_project/manifests/logstash_worker.pp b/modules/openstack_project/manifests/logstash_worker.pp index 74ebcaa16f..a668f4628b 100644 --- a/modules/openstack_project/manifests/logstash_worker.pp +++ b/modules/openstack_project/manifests/logstash_worker.pp @@ -18,6 +18,13 @@ class openstack_project::logstash_worker ( $discover_node = 'elasticsearch01.openstack.org', $filter_rev = 'master', $filter_source = 'https://git.openstack.org/openstack-infra/logstash-filters', + $enable_mqtt = false, + $mqtt_hostname = 'firehose.openstack.org', + $mqtt_port = 8883, + $mqtt_topic = "logstash/${::hostname}", + $mqtt_username = 'infra', + $mqtt_password = undef, + $mqtt_ca_cert_contents = undef, ) { file { '/etc/default/logstash-indexer': ensure => present, @@ -47,9 +54,11 @@ class openstack_project::logstash_worker ( } class { '::logstash::indexer': - input_template => 'openstack_project/logstash/input.conf.erb', - output_template => 'openstack_project/logstash/output.conf.erb', - require => Logstash::Filter['openstack-logstash-filters'], + input_template => 'openstack_project/logstash/input.conf.erb', + output_template => 'openstack_project/logstash/output.conf.erb', + enable_mqtt => $enable_mqtt, + mqtt_ca_cert_contents => $mqtt_ca_cert_contents, + require => Logstash::Filter['openstack-logstash-filters'], } include ::log_processor diff --git a/modules/openstack_project/templates/logstash/output.conf.erb b/modules/openstack_project/templates/logstash/output.conf.erb index d189ccfeac..3f17ca70e4 100644 --- a/modules/openstack_project/templates/logstash/output.conf.erb +++ b/modules/openstack_project/templates/logstash/output.conf.erb @@ -4,4 +4,16 @@ output { manage_template => false flush_size => 1024 } +<% if @enable_mqtt -%> + mqtt { + host => <%= @mqtt_hostname %> + port => <%= @mqtt_port %> + topic => <%= @mqtt_topic %> + username => <%= @mqtt_username %> + password => <%= @mqtt_password %> + ssl => true + ca_file => "/etc/logstash/mqtt-root-CA.crt" + } +<% end -%> + }