2023-11-13 18:20:27 +01:00
|
|
|
# @summary Installs Vector to transform Prometheus data
|
|
|
|
#
|
2024-02-06 21:40:19 +01:00
|
|
|
class kandra::vector {
|
2023-11-13 18:20:27 +01:00
|
|
|
$version = $zulip::common::versions['vector']['version']
|
|
|
|
$dir = "/srv/zulip-vector-${version}"
|
|
|
|
$bin = "${dir}/bin/vector"
|
2024-09-25 19:08:25 +02:00
|
|
|
$conf = '/etc/vector.toml'
|
2023-11-13 18:20:27 +01:00
|
|
|
|
2024-03-25 20:16:16 +01:00
|
|
|
$arch = $facts['os']['architecture'] ? {
|
2023-11-13 18:20:27 +01:00
|
|
|
'amd64' => 'x86_64',
|
|
|
|
'aarch64' => 'aarch64',
|
|
|
|
}
|
|
|
|
|
|
|
|
zulip::external_dep { 'vector':
|
|
|
|
version => $version,
|
|
|
|
url => "https://packages.timber.io/vector/${version}/vector-${version}-${arch}-unknown-linux-gnu.tar.gz",
|
|
|
|
tarball_prefix => "vector-${arch}-unknown-linux-gnu",
|
puppet: Stop relying on "tidy" ordering, which ignores metaparams.
The `tidy` parameter is buggy, and ignores all ordering
metaparameters. This is fixed in Puppet 7[^1], but it's helpful to
resolve it now. Specifically, this fixes bugs with tidy running too
early, and deleting the old version of a package before its new
version is installed or symlinked, leaving a race condition if
anything tries to run the binary in this window.
This is mostly not a problem for Supervisor-managed processes, since
the binary is already running, and can continue to run if it is tidied
out from under the running process. For stand-alone tools like wal-g,
which are run frequently by PostgreSQL, this may cause issues if
PostgreSQL tries to call them during a puppet run.
Remove all complicated uses of tidy, and replace them with an `exec`
which does the equivalent. We also generate `file` resources for
binaries, making them easier (and clearer) to specify as dependencies.
[^1]: https://puppet.atlassian.net/browse/PUP-10688
2024-04-15 20:11:08 +02:00
|
|
|
bin => [$bin],
|
|
|
|
cleanup_after => [Service[supervisor]],
|
2023-11-13 18:20:27 +01:00
|
|
|
}
|
2024-09-25 19:08:25 +02:00
|
|
|
file { "${zulip::common::supervisor_conf_dir}/vector.conf":
|
|
|
|
ensure => file,
|
|
|
|
require => [
|
|
|
|
User[zulip],
|
|
|
|
Package[supervisor],
|
|
|
|
Concat[$conf],
|
|
|
|
File[$bin],
|
|
|
|
],
|
|
|
|
before => Exec['Cleanup vector'],
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
content => template('kandra/supervisor/conf.d/vector.conf.template.erb'),
|
|
|
|
notify => Service[supervisor],
|
|
|
|
}
|
|
|
|
|
|
|
|
exec { 'reload vector':
|
|
|
|
command => 'supervisorctl signal HUP vector',
|
|
|
|
require => Service[supervisor],
|
|
|
|
refreshonly => true,
|
|
|
|
}
|
|
|
|
concat { $conf:
|
|
|
|
ensure => present,
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0644',
|
|
|
|
notify => Exec['reload vector'],
|
|
|
|
}
|
|
|
|
# All of the pipelines need to be included in the Prometheus
|
|
|
|
# exporter; they insert their strings at order 90, with a leading
|
|
|
|
# comma, in the middle of the "inputs" block
|
|
|
|
$vector_export = @(VECTOR)
|
|
|
|
[sources.vector_metrics]
|
|
|
|
type = "internal_metrics"
|
|
|
|
[sinks.prometheus_exporter]
|
|
|
|
type = "prometheus_exporter"
|
|
|
|
address = "0.0.0.0:9081"
|
|
|
|
flush_period_secs = 120
|
|
|
|
suppress_timestamp = true
|
|
|
|
buckets = [0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5]
|
|
|
|
inputs = ["vector_metrics"
|
|
|
|
|-VECTOR
|
|
|
|
concat::fragment { 'vector_export_prefix':
|
|
|
|
target => $conf,
|
|
|
|
content => $vector_export,
|
|
|
|
order => '89',
|
|
|
|
}
|
|
|
|
concat::fragment { 'vector_export_suffix':
|
|
|
|
target => $conf,
|
|
|
|
content => "]\n",
|
|
|
|
order => '99',
|
|
|
|
}
|
2023-11-13 18:20:27 +01:00
|
|
|
}
|