Puppet Class: thanos::query_frontend

Defined in:
modules/thanos/manifests/query_frontend.pp

Overview

Parameters:

  • http_port (Stdlib::Port::Unprivileged) (defaults to: 16902)
  • downstream_url (String) (defaults to: 'http://localhost:10902')
  • log_queries_longer_than (Pattern[/\d+[hms]/]) (defaults to: '20s')
  • max_query_length (Pattern[/\d+[hms]/]) (defaults to: '0s')
  • memcached_hosts (Array[Stdlib::Host]) (defaults to: [])
  • memcached_port (Stdlib::Port) (defaults to: 11211)
  • request_debug (Boolean) (defaults to: false)


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
# File 'modules/thanos/manifests/query_frontend.pp', line 18

class thanos::query_frontend (
    Stdlib::Port::Unprivileged $http_port = 16902,
    String $downstream_url = 'http://localhost:10902',
    Pattern[/\d+[hms]/] $log_queries_longer_than = '20s',
    Pattern[/\d+[hms]/] $max_query_length = '0s',
    Array[Stdlib::Host] $memcached_hosts = [],
    Stdlib::Port $memcached_port = 11211,
    Boolean $request_debug = false,
) {
    ensure_packages(['thanos'])

    $http_address = "0.0.0.0:${http_port}"
    $service_name = 'thanos-query-frontend'
    $cache_config_file = '/etc/thanos-query-frontend/cache.yaml'

    file { '/etc/thanos-query-frontend':
        ensure => directory,
        mode   => '0555',
        owner  => 'root',
        group  => 'root',
    }

    if empty($memcached_hosts) {
      $cache_config = {
        'type'   => 'IN-MEMORY',
        'config' => {
          'max_size'      => '1GB',
          'max_item_size' => '1MB',
        }
      }
    } else {
      $cache_config = {
        'type'   => 'MEMCACHED',
        'config' => {
          'addresses'     => $memcached_hosts.map |$h| { "${h}:${memcached_port}" },
          'timeout'       => '3s',
          'max_item_size' => '1MB',
          'max_async_concurrency' => 20, # Required default to have memcached writes work
          'max_async_buffer_size' => 10000, # Default will be included in Thanos itself, required for now
          'dns_provider_update_interval' => '60s', # https://github.com/thanos-io/thanos/issues/3324
        }
      }
    }

    file { '/usr/local/bin/thanos-query-log-explore':
        ensure => present,
        mode   => '0555',
        owner  => 'root',
        group  => 'root',
        source => 'puppet:///modules/thanos/query-log-explore.py',
    }

    file { $cache_config_file:
        ensure  => present,
        mode    => '0444',
        owner   => 'root',
        group   => 'root',
        content => to_yaml($cache_config),
        notify  => Service[$service_name],
    }

    $logging_config = @("CONFIG")
        http:
          options:
            level: DEBUG
            decision:
              log_start: true
              log_end: true
        | CONFIG

    file { '/etc/thanos-query-frontend/request-logging.yaml':
        ensure  => present,
        content => $logging_config,
    }

    $logging_cmdline = $request_debug ? {
        true    => '--log.level=debug --request.logging-config-file=/etc/thanos-query-frontend/request-logging.yaml',
        default => '',
    }

    systemd::service { $service_name:
        ensure         => present,
        restart        => true,
        override       => true,
        content        => systemd_template('thanos-query-frontend'),
        service_params => {
            enable     => true,
            hasrestart => true,
        },
    }
}