Привет!
Хочу собирать логи со всего домашнего хозяйства в одно место. Решил использовать Grafana + Loki + Alloy (если есть другие варианты - пишите).
Добился того что локи собирает логи из докер контейнеров с помощью плагина для doker.
Теперь пытаюсь отправить логи с openwrt с помощью syslog-ng и ничего не получается.
Всё что прилетает видно в логах контейнера alloy через loki.echo.default.receiver, а вот через Loki ничего на сервере не видно. Ничего вообще не понимаю, не могу понять какие логи смотреть и не понимаю почему это нельзя сделать проще.
Вот конфиг syslog-ng:
ng-open-source-edition
@version: current
@include "scl.conf"
options {
chain_hostnames(no); # Enable or disable the chained hostname format.
create_dirs(yes);
keep_hostname(yes); # Enable or disable hostname rewriting.
log_fifo_size(256); # The number of messages that the output queue can store.
log_msg_size(1024); # Maximum length of a message in bytes.
stats(freq(0)); # The period between two STATS messages (sent by syslog-ng, containing statistics about dropped logs) in seconds.
flush_lines(0); # How many lines are flushed to a destination at a time.
use_fqdn(no); # Add Fully Qualified Domain Name instead of short hostname.
};
# syslog-ng gets messages from syslog-ng (internal) and from /dev/log
source src {
internal();
unix-dgram("/dev/log");
};
source net {
network_localhost();
};
source kernel {
file("/proc/kmsg" program_override("kernel"));
};
destination messages {
file("/var/log/messages");
};
destination d_loki {
network(
"server"
port(3102)
);
};
log {
source(src);
source(net);
source(kernel);
destination(messages);
destination(d_loki);
# uncomment this line to open port 514 to receive messages
#source(s_network);
};
@include "/etc/syslog-ng.d/"
Конфиг alloy:
logging {
level = "info"
format = "logfmt"
}
otelcol.receiver.syslog "default" {
protocol = "rfc3164"
tcp {
listen_address = "0.0.0.0:3102"
}
output {
logs = [otelcol.exporter.syslog.default.input]
}
}
otelcol.exporter.syslog "default" {
endpoint = "localhost"
network = "tcp"
port = 3103
protocol = "rfc5424"
enable_octet_counting = false
tls {
insecure = true
}
}
loki.source.syslog "default" {
listener {
address = "localhost:3103"
protocol = "tcp"
syslog_format = "rfc5424"
label_structured_data = true
use_rfc5424_message = true
}
forward_to = [loki.write.local.receiver,
loki.echo.default.receiver]
}
loki.write "local" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}
loki.echo "default" {}
Конфиг Loki
auth_enabled: false
server:
http_listen_port: 3100
common:
ring:
instance_addr: 127.0.0.1
kvstore:
store: inmemory
replication_factor: 1
path_prefix: /var/loki
schema_config:
configs:
- from: 2020-05-15
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
storage_config:
filesystem:
directory: /var/loki/chunks
analytics:
reporting_enabled: false
limits_config:
retention_period: 30d
compactor:
working_directory: /tmp/loki/retention
delete_request_store: filesystem
retention_enabled: true
retention_delete_delay: 2h