146 lines
3.5 KiB
Plaintext
146 lines
3.5 KiB
Plaintext
logging {
|
|
level = "warn"
|
|
}
|
|
|
|
// ============================================
|
|
// LOKI WRITE TARGET
|
|
// ============================================
|
|
loki.write "loki_srv" {
|
|
endpoint {
|
|
url = sys.env("LOKI_URL")
|
|
}
|
|
}
|
|
|
|
// ============================================
|
|
// HOST JOURNALD SOURCE
|
|
// ============================================
|
|
|
|
// Read journald logs from the host
|
|
loki.source.journal "journal" {
|
|
max_age = "24h"
|
|
relabel_rules = discovery.relabel.host_journal.rules
|
|
forward_to = [loki.process.host_journal.receiver]
|
|
}
|
|
|
|
// ============================================
|
|
// HOST JOURNALD RELABELING
|
|
// ============================================
|
|
|
|
// Convert journald metadata into Loki labels
|
|
discovery.relabel "host_journal" {
|
|
targets = []
|
|
|
|
// Systemd unit name
|
|
rule {
|
|
source_labels = ["__journal__systemd_unit"]
|
|
target_label = "systemd_unit"
|
|
}
|
|
|
|
// Transport type (stdout, syslog, kernel, audit, etc.)
|
|
rule {
|
|
source_labels = ["__journal__transport"]
|
|
target_label = "journal_transport"
|
|
}
|
|
|
|
// Priority (info, warning, error)
|
|
rule {
|
|
source_labels = ["__journal_priority_keyword"]
|
|
target_label = "level"
|
|
}
|
|
}
|
|
|
|
// ============================================
|
|
// HOST JOURNALD PROCESSING
|
|
// ============================================
|
|
|
|
// Add static labels and forward journald logs to Loki
|
|
loki.process "host_journal" {
|
|
stage.static_labels {
|
|
values = {
|
|
cluster = sys.env("CLUSTER_NAME"),
|
|
host = sys.env("HOSTNAME"),
|
|
zone = sys.env("ZONE"),
|
|
job = "integrations/journald",
|
|
}
|
|
}
|
|
|
|
forward_to = [loki.write.loki_srv.receiver]
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
// Metrics: Prometheus connection config
|
|
// ============================================
|
|
|
|
prometheus.remote_write "metrics_service" {
|
|
endpoint {
|
|
url = sys.env("PROMETHEUS_URL")
|
|
}
|
|
|
|
// global labels
|
|
external_labels = {
|
|
cluster = sys.env("CLUSTER_NAME"),
|
|
zone = sys.env("ZONE"),
|
|
}
|
|
}
|
|
|
|
|
|
// ============================================
|
|
// Metrics: Prometheus Unix Exporter
|
|
// ============================================
|
|
|
|
prometheus.exporter.unix "node_exporter" {
|
|
rootfs_path = "/host"
|
|
disable_collectors = ["ipvs", "btrfs", "infiniband", "xfs", "zfs"]
|
|
enable_collectors = [
|
|
"cpu",
|
|
"meminfo",
|
|
"vmstat",
|
|
"loadavg",
|
|
"filesystem",
|
|
"netdev",
|
|
"uname",
|
|
]
|
|
|
|
filesystem {
|
|
mount_points_exclude = "^(/host|/)(etc/resolv.conf|etc/hosts|etc/hostname|etc/machine-id|dataDisks/nvme01-ephemeral/.+|proc|sys|run/containerd/.+|run/k3s/containerd/.+|var/lib/docker/.+|var/lib/kubelet/.+)($|/)"
|
|
fs_types_exclude = "^(tmpfs|shm|autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs|erofs)$"
|
|
mount_timeout = "5s"
|
|
}
|
|
|
|
netclass {
|
|
ignored_devices = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
|
}
|
|
|
|
netdev {
|
|
device_exclude = "^(veth.*|cali.*|[a-f0-9]{15})$"
|
|
}
|
|
}
|
|
|
|
prometheus.scrape "node_exporter" {
|
|
targets = prometheus.exporter.unix.node_exporter.targets
|
|
scrape_interval = "30s"
|
|
|
|
forward_to = [prometheus.relabel.node_exporter.receiver]
|
|
}
|
|
|
|
prometheus.relabel "node_exporter" {
|
|
forward_to = [prometheus.remote_write.metrics_service.receiver]
|
|
|
|
rule {
|
|
action = "replace"
|
|
replacement = sys.env("HOSTNAME")
|
|
target_label = "nodename"
|
|
}
|
|
|
|
rule {
|
|
action = "replace"
|
|
replacement = sys.env("HOSTNAME")
|
|
target_label = "node"
|
|
}
|
|
}
|
|
|
|
|