Defined Type: thanos::sidecar

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

Overview

Parameters:

  • prometheus_port (Stdlib::Port::Unprivileged)
  • prometheus_instance (String[1])
  • http_port (Stdlib::Port::Unprivileged)
  • grpc_port (Stdlib::Port::Unprivileged)
  • base_path (Optional[String]) (defaults to: undef)
  • objstore_account (Optional[Hash[String, String]]) (defaults to: undef)
  • objstore_password (Optional[String]) (defaults to: undef)
  • min_time (Optional[String]) (defaults to: undef)
  • memlimit_ratio (Float[0, 1]) (defaults to: 0.7)
  • tracing_enabled (Boolean) (defaults to: false)
  • limits_request_series (Integer[0]) (defaults to: 0)
  • limits_request_samples (Integer[0]) (defaults to: 0)


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

define thanos::sidecar (
    Stdlib::Port::Unprivileged $prometheus_port,
    String[1] $prometheus_instance,
    Stdlib::Port::Unprivileged $http_port,
    Stdlib::Port::Unprivileged $grpc_port,
    Optional[String] $base_path = undef,
    Optional[Hash[String, String]] $objstore_account = undef,
    Optional[String] $objstore_password = undef,
    Optional[String] $min_time = undef,
    Float[0, 1] $memlimit_ratio = 0.7,
    Boolean $tracing_enabled = false,
    Integer[0] $limits_request_series = 0,
    Integer[0] $limits_request_samples = 0,
) {
    stdlib::ensure_packages(['thanos'])

    $grpc_address = "0.0.0.0:${grpc_port}"
    $http_address = "0.0.0.0:${http_port}"
    $prometheus_base = "/srv/prometheus/${prometheus_instance}"
    $prometheus_url = $base_path ? {
        undef => "http://localhost:${prometheus_port}/${prometheus_instance}",
        '' => "http://localhost:${prometheus_port}/",
        default => "http://localhost:${prometheus_port}${base_path}",
    }
    $service_name = "thanos-sidecar@${title}"
    $tsdb_path = "${prometheus_base}/metrics"
    $objstore_config_file = "/etc/${service_name}/objstore.yaml"
    $tracing_config_file = "/etc/${service_name}/tracing-config.yaml"

    file { "/etc/${service_name}":
        ensure => directory,
        mode   => '0555',
        owner  => 'root',
        group  => 'root',
    }

    # Clean up credentials as needed
    $objstore_config_state = $objstore_account ? {
        undef   => absent,
        default => present,
    }
    $objstore_content = $objstore_account ? {
        undef   => '',
        default => template('thanos/objstore.yaml.erb'),
    }

    file { $objstore_config_file:
        ensure    => $objstore_config_state,
        mode      => '0440',
        owner     => 'prometheus', # sidecar runs as 'prometheus' to be able to read local TSDB
        group     => 'root',
        show_diff => false,
        content   => $objstore_content,
    }

    thanos::tracing { $tracing_config_file:
        service_name => $service_name,
        sampler_type => 'parentbasedalwayssample',
        notify       => Service[$service_name],
    }

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