14
15
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
|
# File 'modules/profile/manifests/thanos/query.pp', line 14
class profile::thanos::query (
Array[String] $sites = lookup('datacenters'),
Hash[String, Hash] $rule_hosts = lookup('profile::thanos::rule_hosts'),
) {
$sd_files = '/etc/thanos-query/stores/*.yml'
$sd_files_path = dirname($sd_files)
$http_port = 10902
class { 'thanos::query':
http_port => $http_port,
sd_files => $sd_files,
}
# Reach out to all sites' sidecars for recent data
$sites.each |String $s| {
prometheus::resource_config{ "thanos_store_sidecar_${s}":
dest => "${sd_files_path}/sidecar_${s}.yml",
prometheus_site => $s,
define_name => 'thanos::sidecar',
port_parameter => 'grpc_port',
}
}
# Reach out to rule component for recording rules
$rule_targets = [ { 'targets' => $rule_hosts.keys.map |$h| { "${h}:17901" } } ]
file { "${sd_files_path}/rule.yml":
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => to_yaml($rule_targets),
}
# Talk to local store for historical data
$local_store = [ { 'targets' => ['localhost:11901'] } ]
file { "${sd_files_path}/local.yml":
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => to_yaml($local_store),
}
ferm::service { 'thanos_query':
proto => 'tcp',
port => $http_port,
srange => '$DOMAIN_NETWORKS',
}
}
|