Changeset View
Changeset View
Standalone View
Standalone View
site-modules/profile/manifests/prometheus/scrape_config.pp
# Scrape configuration for a prometheus exporter | # Scrape configuration for a prometheus exporter | ||||
define profile::prometheus::scrape_config ( | define profile::prometheus::scrape_config ( | ||||
String $prometheus_server, | String $prometheus_server, | ||||
String $target, | String $target, | ||||
String $job, | String $job, | ||||
Hash[String, String] $labels = {}, | Hash[String, String] $labels = {}, | ||||
Optional[Enum['http', 'https']] $scheme = undef, | Optional[Enum['http', 'https']] $scheme = undef, | ||||
Optional[String] $metrics_path = undef, | Optional[String] $metrics_path = undef, | ||||
Optional[Hash[String, Array[String]]] $params = undef, | Optional[Hash[String, Array[String]]] $params = undef, | ||||
Optional[Array[Hash[String, Variant[String, Array[String]]]]] $metric_relabel_configs = undef, | |||||
){ | ){ | ||||
$directory = $profile::prometheus::server::scrape_configs_dir | $directory = $profile::prometheus::server::scrape_configs_dir | ||||
file {"${directory}/${name}.yaml": | file {"${directory}/${name}.yaml": | ||||
ensure => 'present', | ensure => 'present', | ||||
owner => 'root', | owner => 'root', | ||||
group => 'root', | group => 'root', | ||||
mode => '0644', | mode => '0644', | ||||
content => inline_yaml( | content => inline_yaml( | ||||
[ | [ | ||||
{ | { | ||||
job_name => $job, | job_name => $job, | ||||
targets => [$target], | targets => [$target], | ||||
labels => $labels, | labels => $labels, | ||||
scheme => $scheme, | scheme => $scheme, | ||||
metrics_path => $metrics_path, | metrics_path => $metrics_path, | ||||
params => $params, | params => $params, | ||||
metric_relabel_configs => $metric_relabel_configs | |||||
}, | }, | ||||
] | ] | ||||
), | ), | ||||
notify => Exec['update-prometheus-config'], | notify => Exec['update-prometheus-config'], | ||||
} | } | ||||
} | } |