Puppet Class: varnish::logging

Defined in:
modules/varnish/manifests/logging.pp

Overview

Class varnish::logging

This class sets up analytics/logging needed by cache servers

Parameters

cache_cluster

The cache cluster we're part of.

statsd_host

The statsd host to send stats to.

mtail_progs

Directory with mtail programs. Defaults to /etc/mtail.

Parameters:

  • cache_cluster (Any)
  • statsd_host (Any)
  • mtail_progs (Any) (defaults to: '/etc/mtail')
  • mtail_additional_args (Any) (defaults to: '')


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
# File 'modules/varnish/manifests/logging.pp', line 16

class varnish::logging(
    $cache_cluster,
    $statsd_host,
    $mtail_progs='/etc/mtail',
    $mtail_additional_args=''
){
    require_package('python3-logstash')

    rsyslog::conf { 'varnish':
        ensure   => absent,
        priority => 80,
    }

    rsyslog::conf { 'varnish_pipeline':
        content  => template('varnish/rsyslog.conf.erb'),
        priority => 20,
    }

    exec { 'mask_default_mtail':
        command => '/bin/systemctl mask mtail.service',
        creates => '/etc/systemd/system/mtail.service',
    }

    file { '/usr/local/bin/varnishmtail':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        source => 'puppet:///modules/varnish/varnishmtail',
        notify => Systemd::Service['varnishmtail'],
    }

    file { '/etc/default/varnishmtail':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        content => template('varnish/varnishmtail.default.erb'),
        notify  => Systemd::Service['varnishmtail'],
    }

    systemd::service { 'varnishmtail':
        ensure  => present,
        content => systemd_template('varnishmtail'),
        restart => true,
        require => File['/usr/local/bin/varnishmtail'],
    }

    mtail::program { 'varnishreqstats':
        source => 'puppet:///modules/mtail/programs/varnishreqstats.mtail',
        notify => Service['varnishmtail'],
    }

    mtail::program { 'varnishttfb':
        source => 'puppet:///modules/mtail/programs/varnishttfb.mtail',
        notify => Service['varnishmtail'],
    }

    ::varnish::logging::xcache { 'xcache':
    }

    if $cache_cluster == 'upload' {
        # Media browser cache hit rate and request volume stats.
        ::varnish::logging::media { 'media':
        }
    }

    file { "/usr/local/lib/python${::varnish::common::python_version}/dist-packages/wikimedia_varnishlogconsumer.py":
        source => 'puppet:///modules/varnish/wikimedia_varnishlogconsumer.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0644',
    }

    file { '/usr/local/bin/varnishslowlog':
        source => 'puppet:///modules/varnish/varnishslowlog.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { '/usr/local/bin/varnishospital':
        source => 'puppet:///modules/varnish/varnishospital.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { '/usr/local/bin/varnishfetcherr':
        source => 'puppet:///modules/varnish/varnishfetcherr.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { '/usr/local/bin/varnishtlsinspector':
        source => 'puppet:///modules/varnish/varnishtlsinspector.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    systemd::service { 'varnish-frontend-tlsinspector':
        ensure         => absent,
        content        => systemd_template('varnishtlsinspector'),
        restart        => true,
        service_params => {
            require => Service['varnish-frontend'],
            enable  => false,
        },
        subscribe      => [
            File['/usr/local/bin/varnishtlsinspector'],
            File["/usr/local/lib/python${::varnish::common::python_version}/dist-packages/wikimedia_varnishlogconsumer.py"],
        ]
    }
}