feat: add exportarr metrics
- add class to manage the exportarr service - add exportarr to each *arr application
This commit is contained in:
parent
c7e5356444
commit
1156f3d72a
@ -135,6 +135,9 @@ lookup_options:
|
||||
certbot::client::domains:
|
||||
merge:
|
||||
strategy: deep
|
||||
profiles::metrics::exportarr:
|
||||
merge:
|
||||
strategy: deep
|
||||
|
||||
facts_path: '/opt/puppetlabs/facter/facts.d'
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
hiera_include:
|
||||
- lidarr
|
||||
- profiles::nginx::ldapauth
|
||||
- profiles::metrics::exportarr
|
||||
|
||||
# manage lidarr
|
||||
lidarr::params::user: lidarr
|
||||
@ -54,3 +55,11 @@ profiles::consul::client::node_rules:
|
||||
- resource: service
|
||||
segment: lidarr
|
||||
disposition: write
|
||||
|
||||
profiles::metrics::exportarr:
|
||||
app: 'lidarr'
|
||||
config_path: '/opt/lidarr/config.xml'
|
||||
api_key: "%{hiera('lidarr::api_key')}"
|
||||
version: '2.0.1'
|
||||
app_port: "%hiera('lidarr::params::port')"
|
||||
enable_additional_metrics: true
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
hiera_include:
|
||||
- prowlarr
|
||||
- profiles::nginx::ldapauth
|
||||
- profiles::metrics::exportarr
|
||||
|
||||
# manage prowlarr
|
||||
prowlarr::params::user: prowlarr
|
||||
@ -54,3 +55,11 @@ profiles::consul::client::node_rules:
|
||||
- resource: service
|
||||
segment: prowlarr
|
||||
disposition: write
|
||||
|
||||
profiles::metrics::exportarr:
|
||||
app: 'prowlarr'
|
||||
config_path: '/opt/prowlarr/config.xml'
|
||||
api_key: "%{hiera('prowlarr::api_key')}"
|
||||
version: '2.0.1'
|
||||
app_port: "%hiera('prowlarr::params::port')"
|
||||
enable_additional_metrics: true
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
hiera_include:
|
||||
- radarr
|
||||
- profiles::nginx::ldapauth
|
||||
- profiles::metrics::exportarr
|
||||
|
||||
# manage radarr
|
||||
radarr::params::user: radarr
|
||||
@ -55,3 +56,11 @@ profiles::consul::client::node_rules:
|
||||
- resource: service
|
||||
segment: radarr
|
||||
disposition: write
|
||||
|
||||
profiles::metrics::exportarr:
|
||||
app: 'radarr'
|
||||
config_path: '/opt/radarr/config.xml'
|
||||
api_key: "%{hiera('radarr::api_key')}"
|
||||
version: '2.0.1'
|
||||
app_port: "%hiera('radarr::params::port')"
|
||||
enable_additional_metrics: true
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
hiera_include:
|
||||
- readarr
|
||||
- profiles::nginx::ldapauth
|
||||
- profiles::metrics::exportarr
|
||||
|
||||
# manage readarr
|
||||
readarr::params::user: readarr
|
||||
@ -54,3 +55,11 @@ profiles::consul::client::node_rules:
|
||||
- resource: service
|
||||
segment: readarr
|
||||
disposition: write
|
||||
|
||||
profiles::metrics::exportarr:
|
||||
app: 'readarr'
|
||||
config_path: '/opt/readarr/config.xml'
|
||||
api_key: "%{hiera('readarr::api_key')}"
|
||||
version: '2.0.1'
|
||||
app_port: "%hiera('readarr::params::port')"
|
||||
enable_additional_metrics: true
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
hiera_include:
|
||||
- sonarr
|
||||
- profiles::nginx::ldapauth
|
||||
- profiles::metrics::exportarr
|
||||
|
||||
# manage sonarr
|
||||
sonarr::params::user: sonarr
|
||||
|
||||
239
site/profiles/manifests/metrics/exportarr.pp
Normal file
239
site/profiles/manifests/metrics/exportarr.pp
Normal file
@ -0,0 +1,239 @@
|
||||
# Class: profiles::metrics::exportarr
|
||||
#
|
||||
# This module manages exportarr for Prometheus metrics.
|
||||
#
|
||||
# @param arch
|
||||
# Architecture (amd64 or i386)
|
||||
#
|
||||
# @param bin_dir
|
||||
# Directory where binaries are located
|
||||
#
|
||||
# @param config_mode
|
||||
# The permissions of the configuration files
|
||||
#
|
||||
# @param download_extension
|
||||
# Extension for the release binary archive
|
||||
#
|
||||
# @param download_url
|
||||
# Complete URL where the release binary archive can be downloaded
|
||||
#
|
||||
# @param download_url_base
|
||||
# Base URL for the binary archive
|
||||
#
|
||||
# @param extra_groups
|
||||
# Extra groups to add the binary user to
|
||||
#
|
||||
# @param extra_options
|
||||
# Extra options added to the startup command
|
||||
#
|
||||
# @param env_vars
|
||||
# The environment variables to pass to the daemon
|
||||
#
|
||||
# @param group
|
||||
# Group under which the binary is running
|
||||
#
|
||||
# @param init_style
|
||||
# Service startup scripts style (e.g. rc, upstart or systemd)
|
||||
#
|
||||
# @param install_method
|
||||
# Installation method: url or package (only url is supported currently)
|
||||
#
|
||||
# @param manage_group
|
||||
# Whether to create a group or rely on external code for that
|
||||
#
|
||||
# @param manage_service
|
||||
# Should Puppet manage the service? (default true)
|
||||
#
|
||||
# @param manage_user
|
||||
# Whether to create user or rely on external code for that
|
||||
#
|
||||
# @param os
|
||||
# Operating system (linux is the only one supported)
|
||||
#
|
||||
# @param package_ensure
|
||||
# If package, then use this for package ensure (default 'latest')
|
||||
#
|
||||
# @param package_name
|
||||
# The binary package name - not available yet
|
||||
#
|
||||
# @param purge_config_dir
|
||||
# Purge config files no longer generated by Puppet
|
||||
#
|
||||
# @param restart_on_change
|
||||
# Should Puppet restart the service on configuration change? (default true)
|
||||
#
|
||||
# @param service_enable
|
||||
# Whether to enable the service from Puppet (default true)
|
||||
#
|
||||
# @param service_ensure
|
||||
# State ensured for the service (default 'running')
|
||||
#
|
||||
# @param service_name
|
||||
# Name of the exportarr service (default 'exportarr')
|
||||
#
|
||||
# @param user
|
||||
# User which runs the service
|
||||
#
|
||||
# @param version
|
||||
# The binary release version
|
||||
#
|
||||
# @param export_scrape_job
|
||||
# Whether to export a `prometheus::scrape_job` to PuppetDB for
|
||||
# collecting on your Prometheus server.
|
||||
#
|
||||
# @param scrape_job_name
|
||||
# The name of the scrape job. When configuring Prometheus with this
|
||||
# Puppet module, the jobs to be collected are configured with
|
||||
# `prometheus::collect_scrape_jobs`.
|
||||
#
|
||||
# @param scrape_port
|
||||
# The port to use in the scrape job. This won't normally need to be
|
||||
# changed unless you run the exporter with a non-default port by
|
||||
# overriding `extra_options`.
|
||||
#
|
||||
# @param scrape_job_labels
|
||||
# Labels to configure on the scrape job. If not set, the
|
||||
# `prometheus::daemon` default (`{ 'alias' => $scrape_host }`) will
|
||||
# be used.
|
||||
#
|
||||
# @param proxy_server
|
||||
# Optional proxy server, with port number if needed, e.g., https://example.com:8080
|
||||
#
|
||||
# @param proxy_type
|
||||
# Optional proxy server type (none|http|https|ftp)
|
||||
#
|
||||
# @param app
|
||||
# Application name (e.g., sonarr, radarr, or lidarr)
|
||||
#
|
||||
# @param config_path
|
||||
# Path to Sonarr, Radarr, or Lidarr's config.xml (advanced)
|
||||
#
|
||||
# @param api_key
|
||||
# API Key for Sonarr, Radarr, or Lidarr
|
||||
#
|
||||
# @param api_key_file
|
||||
# API Key file location for Sonarr, Radarr, or Lidarr
|
||||
#
|
||||
# @param interface
|
||||
# The interface IP Exportarr will listen on
|
||||
#
|
||||
# @param enable_additional_metrics
|
||||
# Set to true to enable gathering of additional metrics (slow)
|
||||
|
||||
class profiles::metrics::exportarr (
|
||||
Optional[Stdlib::HTTPSUrl] $download_url = undef,
|
||||
Array[String[1]] $extra_groups = [],
|
||||
String[1] $group = 'exportarr',
|
||||
String[1] $package_ensure = 'latest',
|
||||
String[1] $package_name = 'exportarr',
|
||||
String[1] $user = 'exportarr',
|
||||
String[1] $version = '2.0.1',
|
||||
Boolean $purge_config_dir = true,
|
||||
Boolean $restart_on_change = true,
|
||||
Boolean $service_enable = true,
|
||||
String[1] $service_ensure = 'running',
|
||||
String[1] $service_name = 'exportarr',
|
||||
Prometheus::Initstyle $init_style = $facts['service_provider'],
|
||||
Prometheus::Install $install_method = 'url',
|
||||
Boolean $manage_group = true,
|
||||
Boolean $manage_service = true,
|
||||
Boolean $manage_user = true,
|
||||
String[1] $os = downcase($facts['kernel']),
|
||||
Optional[String[1]] $extra_options = undef,
|
||||
Hash[String, Scalar] $env_vars = {},
|
||||
String $download_extension = 'tar.gz',
|
||||
Stdlib::HTTPSUrl $download_url_base = 'https://github.com/onedr0p/exportarr/releases',
|
||||
String[1] $config_mode = '0640',
|
||||
String[1] $arch = $facts['os']['architecture'],
|
||||
Stdlib::Absolutepath $bin_dir = '/usr/local/bin',
|
||||
Boolean $export_scrape_job = false,
|
||||
Stdlib::Port $scrape_port = 9707,
|
||||
Stdlib::Port $app_port = 8000,
|
||||
Stdlib::Host $app_addr = '127.0.0.1',
|
||||
String[1] $scrape_job_name = 'exportarr',
|
||||
Optional[Hash] $scrape_job_labels = undef,
|
||||
Optional[String[1]] $proxy_server = undef,
|
||||
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
|
||||
String[1] $app = 'sonarr',
|
||||
Optional[Stdlib::Absolutepath] $config_path = undef,
|
||||
String[1] $api_key = '',
|
||||
Optional[Stdlib::Absolutepath] $api_key_file = undef,
|
||||
Optional[Stdlib::IP::Address::V4] $interface = undef,
|
||||
Boolean $enable_additional_metrics = false,
|
||||
) {
|
||||
|
||||
$real_arch = $arch ? {
|
||||
'x86_64' => 'amd64',
|
||||
'i386' => '386',
|
||||
'aarch64' => 'arm64',
|
||||
'armv7l' => 'armv7',
|
||||
'armv6l' => 'armv6',
|
||||
'armv5l' => 'armv5',
|
||||
default => $arch,
|
||||
}
|
||||
# Construct the real download URL if not provided
|
||||
$real_download_url = pick(
|
||||
$download_url,
|
||||
"${download_url_base}/download/v${version}/${package_name}_${version}_${os}_${real_arch}.${download_extension}"
|
||||
)
|
||||
|
||||
# Determine if the service should be notified
|
||||
$notify_service = $restart_on_change ? {
|
||||
true => Service[$service_name],
|
||||
default => undef,
|
||||
}
|
||||
|
||||
# Define the startup options
|
||||
$startup_options = [
|
||||
$app,
|
||||
"--port ${scrape_port}",
|
||||
"--url http://${app_addr}:${app_port}",
|
||||
"--api-key ${api_key}",
|
||||
$extra_options,
|
||||
]
|
||||
|
||||
# Add advanced options if provided
|
||||
unless $config_path == undef {
|
||||
$startup_options = concat($startup_options, ["--config ${config_path}"])
|
||||
}
|
||||
unless $api_key_file == undef {
|
||||
$startup_options = concat($startup_options, ["--api-key-file ${api_key_file}"])
|
||||
}
|
||||
unless $interface == undef {
|
||||
$startup_options = concat($startup_options, ["--interface ${interface}"])
|
||||
}
|
||||
if $enable_additional_metrics {
|
||||
$startup_options = concat($startup_options, ['--enable-additional-metrics'])
|
||||
}
|
||||
|
||||
prometheus::daemon { $service_name:
|
||||
install_method => $install_method,
|
||||
version => $version,
|
||||
download_extension => $download_extension,
|
||||
os => $os,
|
||||
arch => $arch,
|
||||
real_download_url => $real_download_url,
|
||||
bin_dir => $bin_dir,
|
||||
notify_service => $notify_service,
|
||||
package_name => $package_name,
|
||||
package_ensure => $package_ensure,
|
||||
manage_user => $manage_user,
|
||||
user => $user,
|
||||
extra_groups => $extra_groups,
|
||||
group => $group,
|
||||
manage_group => $manage_group,
|
||||
purge => $purge_config_dir,
|
||||
options => join($startup_options, ' '),
|
||||
env_vars => $env_vars,
|
||||
init_style => $init_style,
|
||||
service_ensure => $service_ensure,
|
||||
service_enable => $service_enable,
|
||||
manage_service => $manage_service,
|
||||
export_scrape_job => $export_scrape_job,
|
||||
scrape_port => $scrape_port,
|
||||
scrape_job_name => $scrape_job_name,
|
||||
scrape_job_labels => $scrape_job_labels,
|
||||
proxy_server => $proxy_server,
|
||||
proxy_type => $proxy_type,
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user