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)


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/sidecar.pp', line 19

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,
) {
    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"

    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,
    }

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