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 (String) (defaults to: '20s')
  • memcached_hosts (Array[Stdlib::Host]) (defaults to: [])
  • memcached_port (Stdlib::Port) (defaults to: 11211)


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

class thanos::query_frontend (
    Stdlib::Port::Unprivileged $http_port = 16902,
    String $downstream_url = 'http://localhost:10902',
    String $log_queries_longer_than = '20s',
    Array[Stdlib::Host] $memcached_hosts = [],
    Stdlib::Port $memcached_port = 11211,
) {
    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 { $cache_config_file:
        ensure  => present,
        mode    => '0444',
        owner   => 'root',
        group   => 'root',
        content => to_yaml($cache_config),
        notify  => Service[$service_name],
    }

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