65 lines
1.4 KiB
Plaintext
65 lines
1.4 KiB
Plaintext
<% if @ay_manage_loki == true -%>
|
|
|
|
// 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"
|
|
}
|
|
|
|
loki.process "syslog" {
|
|
stage.regex {
|
|
expression = `(?P<ts>[A-Z][a-z]{2}\s{1,2}\d{1,2}\s\d{2}:\d{2}:\d{2})\s(?P<host>[\w\.\@-]+)\s(?P<log>.*)$`
|
|
}
|
|
stage.labels {
|
|
values = {
|
|
hostname = "${host}"
|
|
}
|
|
}
|
|
stage.timestamp {
|
|
source = "ts"
|
|
format = "Jan _2 15:04:05"
|
|
}
|
|
stage.output {
|
|
source = "log"
|
|
}
|
|
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 -%>
|
|
// Metrics collection
|
|
prometheus.exporter.unix "system_metrics" {
|
|
include_exporter_metrics = true
|
|
disable_collectors = ["mdadm"]
|
|
}
|
|
|
|
prometheus.scrape "scrape_system" {
|
|
targets = prometheus.exporter.unix.system_metrics.targets
|
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
scrape_interval = "15s"
|
|
}
|
|
|
|
prometheus.remote_write "prometheus" {
|
|
endpoint {
|
|
url = "<%= @ay_prom_url %>"
|
|
basic_auth {
|
|
username = "<%= @ay_loki_username %>"
|
|
password = "<%= @ay_loki_userpass %>"
|
|
}
|
|
}
|
|
}
|
|
<% end %> |