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
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
|
# File 'modules/profile/manifests/thanos/rule/main.pp', line 15
class profile::thanos::rule::main (
Hash[Stdlib::Fqdn, Hash] $thanos_rule_hosts = lookup('profile::thanos::rule_hosts'),
Array $query_hosts = lookup('profile::thanos::frontends'),
Hash[String, String] $objstore_account = lookup('profile::thanos::objstore_account'),
String $objstore_password = lookup('profile::thanos::objstore_password'),
Array[Stdlib::Host] $alertmanagers = lookup('alertmanagers'),
String $public_domain = lookup('public_domain'),
Optional[Integer] $object_store_cutoff_days = lookup('profile::thanos::object_store_cutoff_days', { 'default_value' => undef}),
) {
$http_port = 17902
$grpc_port = 17901
thanos::rule { 'main':
alertmanagers => $alertmanagers,
# rule_files will be automatically merged with the default /etc/thanos-rule@ paths for puppet-deployed
# files, whereas /srv paths will receive rules/alerts deployed by other means.
rule_files => ['/srv/alerts-thanos/*.yaml',
'/etc/pyrra/output-rules/*.yaml'],
rule_hosts => $thanos_rule_hosts,
use_objstore => true,
objstore_account => $objstore_account,
objstore_password => $objstore_password,
http_port => $http_port,
grpc_port => $grpc_port,
query_url => "https://thanos.${public_domain}",
# Thanos Rule accepts input in the form of an interval (e.g., '15d' represents 15 days).
# The cutoff parameter is expressed in days as an Integer, and here we adjust the format to the correct string.
retention_time => sprintf('%dd', $object_store_cutoff_days + 1),
tracing_enabled => true,
query_hosts => $query_hosts,
}
profile::thanos::query::store_config { 'main':
hosts => $thanos_rule_hosts,
grpc_port => $grpc_port,
}
if $::fqdn in $thanos_rule_hosts {
# placeholder class to be able to fetch thanos-rule hosts
# as Prometheus job targets
class { 'thanos::rule::prometheus': }
prometheus::pint::source { 'thanos-query-frontend':
port => 16902,
url_path => '',
all_alerts => true,
}
# promql/rate needs to read Prometheus config via
# /api/v1/status/config which Thanos doesn't expose or proxy
prometheus::pint::config { 'disable-checks':
content => @(CONFIG)
checks {
disabled = ["promql/rate"]
}
|- CONFIG
}
} else {
class { 'prometheus::pint':
ensure => absent,
}
}
# Deploy Thanos recording rules
thanos::recording_rule { 'recording_rules.yaml':
source => 'puppet:///modules/profile/thanos/recording_rules.yaml',
}
# Deploy Thanos metamonitoring rules
thanos::recording_rule { 'metamonitoring_rules.yaml':
source => 'puppet:///modules/profile/thanos/metamonitoring_rules.yaml',
}
}
|