add prometheus static labels fqdn

This commit is contained in:
Arne Teuke
2025-03-12 14:10:29 +01:00
parent 17aae3e03e
commit 0b2b6fedc2
2 changed files with 12 additions and 11 deletions

View File

@@ -10,10 +10,6 @@
# @param [boolean] ay_manage_prom whether to manage metric forwarding # @param [boolean] ay_manage_prom whether to manage metric forwarding
# @param [string] ay_prom_url the url where alloy will send metrics # @param [string] ay_prom_url the url where alloy will send metrics
# @param [array] ay_log_targets the logging targets # @param [array] ay_log_targets the logging targets
# @param [boolean] ay_manage_user whether to manage user settings
# @param [string] ay_user the alloy user name
# @param [array] ay_groups which groups the user should be in
# @param [string] ay_user_shell which shell to use
# @summary Class contains all parameters for the alloy_cd module. # @summary Class contains all parameters for the alloy_cd module.
############################################################################## ##############################################################################
class alloy_cd::params ( class alloy_cd::params (
@@ -32,12 +28,6 @@ class alloy_cd::params (
Boolean $ay_manage_prom = true, Boolean $ay_manage_prom = true,
String $ay_prom_url = 'https://prometheus.example.net/api/v1/write', String $ay_prom_url = 'https://prometheus.example.net/api/v1/write',
# user
Boolean $ay_manage_user = true,
String $ay_user = 'alloy',
Array $ay_groups = ['systemd-journal','adm'],
String $ay_user_shell = '/sbin/nologin',
) { ) {
# service # service
$ay_service = 'alloy' $ay_service = 'alloy'

View File

@@ -61,10 +61,21 @@ prometheus.exporter.unix "system_metrics" {
prometheus.scrape "scrape_system" { prometheus.scrape "scrape_system" {
targets = prometheus.exporter.unix.system_metrics.targets targets = prometheus.exporter.unix.system_metrics.targets
forward_to = [prometheus.remote_write.prometheus.receiver] forward_to = [prometheus.process.metrics.receiver]
scrape_interval = "15s" scrape_interval = "15s"
} }
prometheus.process "metrics" {
stage.static_labels {
values = {
fqdn = constants.hostname,
service = "prometheus",
}
}
forward_to = [prometheus.remote_write.prometheus.receiver]
}
prometheus.remote_write "prometheus" { prometheus.remote_write "prometheus" {
endpoint { endpoint {
url = "<%= @ay_prom_url %>" url = "<%= @ay_prom_url %>"