Files
ansible.collection.globals/roles/grafana_alloy/templates/config.alloy.j2
T
Márcio Fernandes 361e753f1a
image-deploy.yaml / build-push-image (push) Successful in 24s
modified: roles/grafana_alloy/templates/config.alloy.j2
2026-09-20 11:03:29 +00:00

118 lines
3.0 KiB
Django/Jinja

// metrics - prometheus srv
prometheus.remote_write "prom_srv" {
endpoint {
url = "{{ prometheus.remote_write.endpoint.url }}"
}
// global labels
external_labels = {
cluster = sys.env("CLUSTER_NAME"),
zone = sys.env("ZONE"),
job = "integrations/unix",
}
}
// metrics - scrape config
prometheus.scrape "integrations_node_exporter" {
scrape_interval = "15s"
targets = prometheus.exporter.unix.integrations_node_exporter.targets
forward_to = [prometheus.remote_write.prom_srv.receiver]
}
// metrics - node exporter
prometheus.exporter.unix "integrations_node_exporter" {
disable_collectors = ["ipvs", "btrfs", "infiniband", "xfs", "zfs"]
enable_collectors = ["meminfo"]
filesystem {
fs_types_exclude = "^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|tmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
mount_points_exclude = "^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+)($|/)"
mount_timeout = "5s"
}
netclass {
ignored_devices = "^(veth.*|cali.*|[a-f0-9]{15})$"
}
netdev {
device_exclude = "^(veth.*|cali.*|[a-f0-9]{15})$"
}
}
// ============================================
// LOKI WRITE TARGET
// ============================================
loki.write "loki_srv" {
endpoint {
url = "{{ loki.endpoint.url }}"
}
}
// ============================================
// JOURNALD SOURCE
// ============================================
// Read journald logs
loki.source.journal "journal" {
max_age = "24h"
relabel_rules = discovery.relabel.journal.rules
forward_to = [loki.process.journal.receiver]
}
// ============================================
// HOST JOURNALD PROCESSING
// ============================================
// Add static labels and forward journald logs to Loki
loki.process "journal" {
stage.static_labels {
values = {
job = "integrations/journald",
host = "{{ inventory_hostname }}",
{% if loki.labels is defined and loki.labels %}
{% for key, value in loki.labels.items() %}
{{ key }} = "{{ value }}",
{% endfor %}
{% endif %}
}
}
forward_to = [loki.write.loki_srv.receiver]
}
// ============================================
// HOST JOURNALD RELABELING
// ============================================
// Convert journal metadata into Loki labels
discovery.relabel "journal" {
targets = []
// syslog_identifier
rule {
source_labels = ["__journal_syslog_identifier"]
target_label = "syslog_identifier"
}
// 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"
}
}