Puppet Class: simp_logstash::input::syslog
- Defined in:
- manifests/input/syslog.pp
Overview
A Logstash input for Syslog messages
Though this class has a great deal repeated with the other input classes, they remain separate in the event that variables need to be added in the future for ERB processing.
It allows you to encrypt traffic to the LogStash log collector just like the SIMP rsyslog remote configuration.
IPTables NAT rules are modified so that LogStash can run as a normal user while collecting syslog traffic from other hosts.
This is currently configured as a catch-all type of system. There is no output filtering. If you need logstash filters or additional inputs/outputs, you will need to configure them separately.
See simp_logstash::clean if you want to automatically prune your logs to conserve ElasticSearch storage space.
This class is incompatible with the SIMP rsyslog::stock::server class!
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'manifests/input/syslog.pp', line 91
class simp_logstash::input::syslog (
$add_field = {},
$codec = '',
$facility_labels = [],
$host = '127.0.0.1',
$locale = '',
$severity_labels = [
'Emergency',
'Alert',
'Critical',
'Error',
'Warning',
'Notice',
'Informational',
'Debug'
],
$lstash_tags = '',
$timezone = '',
$lstash_type = '',
$use_labels = true,
$order = '50',
$content = '',
$client_nets = defined('$::client_nets') ? { true => getvar('::client_nets'), default => hiera('client_nets','127.0.0.1') },
$listen_plain_tcp = false,
$listen_plain_udp = false,
$tcp_port = '514',
$udp_port = '514',
$daemon_port = '51400',
$stunnel_syslog_input = true,
$stunnel_syslog_port = '6514',
$simp_sysctl = true,
$simp_iptables = defined('$::use_iptables') ? { true => getvar('::use_iptables'), default => hiera('use_iptables',true) }
) {
validate_hash($add_field)
validate_string($codec)
validate_array($facility_labels)
validate_net_list($host)
validate_string($locale)
validate_array($severity_labels)
validate_string($lstash_tags)
validate_string($timezone)
validate_string($lstash_type)
validate_bool($use_labels)
validate_integer($order)
validate_string($content)
validate_net_list($client_nets)
validate_bool($listen_plain_tcp)
validate_bool($listen_plain_udp)
validate_port($udp_port)
validate_port($tcp_port)
validate_port($daemon_port)
validate_bool($stunnel_syslog_input)
validate_port($stunnel_syslog_port)
validate_bool($simp_sysctl)
validate_bool($simp_iptables)
### Common material to all inputs
include '::simp_logstash'
$_component_name = 'syslog'
$_group = 'input'
$_group_order = $::simp_logstash::config_order[$_group]
if empty($content) {
$_content = template("${module_name}/${_group}/${_component_name}.erb")
}
else {
$_content = $content
}
file { "${::simp_logstash::config_prefix}-${_group_order}_${_group}-${order}-${_component_name}${::simp_logstash::config_suffix}":
ensure => 'file',
owner => 'root',
group => $::logstash::logstash_group,
mode => '0640',
content => $_content,
notify => Class['logstash::service']
}
### End common material
if $simp_iptables {
if $listen_plain_tcp or $listen_plain_udp {
if $listen_plain_tcp {
# IPTables rules so that LogStash doesn't have to run as root.
iptables_rule { 'tcp_logstash_syslog_redirect':
table => 'nat',
absolute => true,
first => true,
order => '1',
header => false,
content => "-A PREROUTING -p tcp -m tcp --dport ${tcp_port} -j DNAT --to-destination ${host}:${daemon_port}"
}
}
if $listen_plain_udp {
# IPTables rules so that LogStash doesn't have to run as root.
iptables_rule { 'udp_logstash_syslog_redirect':
table => 'nat',
absolute => true,
first => true,
order => '1',
header => false,
content => "-A PREROUTING -p udp -m udp --dport ${udp_port} -j DNAT --to-destination ${host}:${daemon_port}"
}
}
if $simp_sysctl {
include '::sysctl'
# Allow the iptables NAT rules to work properly.
sysctl::value { 'net.ipv4.conf.all.route_localnet': value => '1' }
}
}
if $listen_plain_tcp {
iptables::add_tcp_stateful_listen { 'logstash_syslog_tcp':
client_nets => $client_nets,
dports => $tcp_port
}
iptables_rule { 'logstash_syslog_tcp_allow':
content => "-d ${host} -p tcp -m tcp -m multiport --dports ${daemon_port} -j ACCEPT"
}
}
if $listen_plain_udp {
iptables::add_udp_listen { 'logstash_syslog_udp':
client_nets => $client_nets,
dports => $udp_port
}
iptables_rule { 'logstash_syslog_udp_allow':
content => "-d ${host} -p udp -m udp -m multiport --dports ${daemon_port} -j ACCEPT"
}
}
}
if $stunnel_syslog_input {
include '::stunnel'
include '::tcpwrappers'
stunnel::add { 'logstash_syslog_tls':
client => false,
connect => [$daemon_port],
accept => $stunnel_syslog_port
}
tcpwrappers::allow { ['logstash_syslog','logstash_syslog_tls']: pattern => 'ALL' }
}
}
|