feat: shipping de logs journald a Loki (config loki_url + shipper journalctl→PushLokiStream)

This commit is contained in:
Egutierrez
2026-06-07 13:22:00 +02:00
parent a6e40eeb41
commit 2176e9d442
3 changed files with 174 additions and 9 deletions
+7 -3
View File
@@ -11,10 +11,11 @@ import (
// systemd drop-ins and for deploying the same binary to many nodes.
type Config struct {
Node string `json:"node"` // value of the "instance" label attached to every series
HubURL string `json:"hub_url"` // full ingest URL, e.g. https://metrics-…/api/v1/import/prometheus
User string `json:"user"` // basic-auth user (empty disables auth)
HubURL string `json:"hub_url"` // full metrics ingest URL, e.g. https://metrics-…/api/v1/import/prometheus
LokiURL string `json:"loki_url"` // full Loki push URL, e.g. https://logs-…/loki/api/v1/push (empty disables log shipping)
User string `json:"user"` // basic-auth user, shared by metrics and logs (empty disables auth)
Pass string `json:"pass"` // basic-auth password
IntervalSec int `json:"interval_sec"` // push period in seconds (default 15)
IntervalSec int `json:"interval_sec"` // metrics push period in seconds (default 15)
}
// defaultConfig returns the baseline configuration: the machine hostname as the
@@ -44,6 +45,9 @@ func loadConfig(path string) (Config, error) {
if v := os.Getenv("FLEET_HUB_URL"); v != "" {
cfg.HubURL = v
}
if v := os.Getenv("FLEET_LOKI_URL"); v != "" {
cfg.LokiURL = v
}
if v := os.Getenv("FLEET_USER"); v != "" {
cfg.User = v
}