add define for logs
This commit is contained in:
@@ -18,87 +18,4 @@ loki.process "alloy" {
|
||||
// Define file discovery for your logs
|
||||
local.file_match "system_logs" {
|
||||
path_targets = [
|
||||
<% @log_targets_array.each do |target| -%>
|
||||
{__path__ = "<%= target %>"},
|
||||
<% end -%>
|
||||
]
|
||||
sync_period = "5s"
|
||||
}
|
||||
|
||||
// Scrape the logs from the matched files
|
||||
loki.source.file "system_logs" {
|
||||
targets = local.file_match.system_logs.targets
|
||||
forward_to = [loki.process.syslog.receiver]
|
||||
}
|
||||
|
||||
loki.process "syslog" {
|
||||
|
||||
stage.static_labels {
|
||||
values = {
|
||||
fqdn = constants.hostname,
|
||||
service = "linux_logs",
|
||||
}
|
||||
}
|
||||
forward_to = [loki.write.loki.receiver]
|
||||
}
|
||||
|
||||
loki.write "loki" {
|
||||
endpoint {
|
||||
url = "<%= @ay_loki_url %>"
|
||||
basic_auth {
|
||||
username = "<%= @ay_loki_username %>"
|
||||
password = "<%= @ay_loki_userpass %>"
|
||||
}
|
||||
}
|
||||
}
|
||||
<% end -%>
|
||||
<% if @ay_manage_prom == true -%>
|
||||
// 1. Exporter (or keep your existing node_exporter binary)
|
||||
prometheus.exporter.unix "node" {
|
||||
// optional: disable unused collectors
|
||||
// disable_collectors = ["ipvs", "btrfs", ...]
|
||||
}
|
||||
|
||||
// 2. Relabel the targets so instance = real hostname
|
||||
discovery.relabel "node_exporter" {
|
||||
targets = prometheus.exporter.unix.node.targets
|
||||
|
||||
rule {
|
||||
target_label = "instance"
|
||||
replacement = constants.hostname
|
||||
}
|
||||
|
||||
rule {
|
||||
target_label = "job"
|
||||
replacement = "integrations/node_exporter"
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Scrape the properly labeled targets
|
||||
prometheus.scrape "node_exporter" {
|
||||
targets = discovery.relabel.node_exporter.output
|
||||
forward_to = [prometheus.remote_write.prometheus.receiver]
|
||||
scrape_interval = "15s"
|
||||
honor_timestamps = <%= @ay_prom_honor_timestamps %>
|
||||
track_timestamps_staleness = <%= @ay_prom_track_timestamps_staleness %>
|
||||
}
|
||||
|
||||
prometheus.remote_write "prometheus" {
|
||||
external_labels = {
|
||||
// makes every series from this Alloy unmistakably unique
|
||||
alloy_instance = constants.hostname,
|
||||
}
|
||||
endpoint {
|
||||
url = "<%= @ay_prom_url %>"
|
||||
basic_auth {
|
||||
username = "<%= @ay_loki_username %>"
|
||||
password = "<%= @ay_loki_userpass %>"
|
||||
}
|
||||
queue_config {
|
||||
max_shards = <%= @ay_prom_max_shards %>
|
||||
max_samples_per_send = <%= @ay_prom_max_samples_per_send %>
|
||||
batch_send_deadline = "<%= @ay_prom_batch_send_deadline %>"
|
||||
}
|
||||
}
|
||||
}
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user