add prom logic and variables
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
# @param [string] ay_loki_url the url where alloy will send logs to.
|
# @param [string] ay_loki_url the url where alloy will send logs to.
|
||||||
# @param [string] ay_loki_username the username to logon to loki
|
# @param [string] ay_loki_username the username to logon to loki
|
||||||
# @param [string] ay_loki_userpass the password to logon to loki
|
# @param [string] ay_loki_userpass the password to logon to loki
|
||||||
|
# @param [boolean] ay_manage_loki whether to manage log forwarding to loki
|
||||||
|
# @param [boolean] ay_manage_prom whether to manage metric forwarding
|
||||||
|
# @param [string] ay_prom_url the url where alloy will send metrics
|
||||||
# @summary Class contains all parameters for the cd_alloy module.
|
# @summary Class contains all parameters for the cd_alloy module.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
class cd_alloy::params (
|
class cd_alloy::params (
|
||||||
@@ -14,13 +17,15 @@ $reqpackages = 'alloy',
|
|||||||
$pkg_ensure = 'latest',
|
$pkg_ensure = 'latest',
|
||||||
|
|
||||||
# loki
|
# loki
|
||||||
|
$ay_manage_loki = true,
|
||||||
$ay_loki_url = 'https://loki.example.net/loki/api/v1/push',
|
$ay_loki_url = 'https://loki.example.net/loki/api/v1/push',
|
||||||
$ay_loki_username = '',
|
$ay_loki_username = '',
|
||||||
$ay_loki_userpass = '',
|
$ay_loki_userpass = '',
|
||||||
$ay_log_targets = [
|
$ay_log_targets = ['/var/log/messages','/var/log/secure',],
|
||||||
'/var/log/messages',
|
|
||||||
'/var/log/secure',
|
# prometheus
|
||||||
],
|
$ay_manage_prom = true,
|
||||||
|
$ay_prom_url = 'https://prometheus.example.net/api/v1/write',
|
||||||
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<% if @ay_manage_loki == true -%>
|
||||||
logging {
|
logging {
|
||||||
level = "info"
|
level = "info"
|
||||||
format = "logfmt"
|
format = "logfmt"
|
||||||
@@ -21,3 +22,27 @@ loki.write "loki" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<% end -%>
|
||||||
|
<% if @ay_manage_prom == true -%>
|
||||||
|
// Metrics collection
|
||||||
|
prometheus.exporter.unix "system_metrics" {
|
||||||
|
include_exporter_metrics = true
|
||||||
|
disable_collectors = ["mdadm"] # Optional: adjust based on your needs
|
||||||
|
}
|
||||||
|
|
||||||
|
prometheus.scrape "scrape_system" {
|
||||||
|
targets = prometheus.exporter.unix.system_metrics.targets
|
||||||
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
||||||
|
scrape_interval = "15s" # Adjust as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
prometheus.remote_write "prometheus" {
|
||||||
|
endpoint {
|
||||||
|
url = "<%= @ay_prom_url %>"
|
||||||
|
basic_auth {
|
||||||
|
username = "<%= @ay_loki_username %>"
|
||||||
|
password = "<%= @ay_loki_userpass %>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% end %>
|
||||||
Reference in New Issue
Block a user