fix(logs): Zeitbudget im journal-tail (exec timed out bei grossem Journal)

This commit is contained in:
mm committed 2026-09-13 22:29:55 +02:00
1 parent 8990124c2b
commit b49f9ccbfd
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -21,6 +21,10 @@
set -u set -u
PRIORITY="${JOURNAL_PRIORITY:-warning}" # warning|err|info|debug PRIORITY="${JOURNAL_PRIORITY:-warning}" # warning|err|info|debug
# Hartes Zeitbudget: Telegraf bricht den exec sonst ab (timeout 25s bei
# interval 30s). Wir lesen nie laenger als BUDGET Sekunden pro Aufruf — der
# Cursor macht den Rest beim naechsten Lauf.
BUDGET="${JOURNAL_BUDGET:-15}"
SINCE="${JOURNAL_SINCE:-}" # optional, nur beim Erstanlauf SINCE="${JOURNAL_SINCE:-}" # optional, nur beim Erstanlauf
MAX_LINES="${JOURNAL_MAX_LINES:-500}" # Schutz vor Flut pro Lauf MAX_LINES="${JOURNAL_MAX_LINES:-500}" # Schutz vor Flut pro Lauf
STATE_DIR="${JOURNAL_STATE_DIR:-/var/lib/telegraf-journal}" STATE_DIR="${JOURNAL_STATE_DIR:-/var/lib/telegraf-journal}"
@@ -39,7 +43,9 @@ fi
last_cursor="" last_cursor=""
journalctl "${args[@]}" 2>/dev/null | while IFS= read -r line; do # --no-pager + hartes Zeitlimit: journalctl kann bei viel Aufkommen laenger
# brauchen als Telegrafs timeout erlaubt.
timeout -k 2 "$BUDGET" journalctl "${args[@]}" 2>/dev/null | while IFS= read -r line; do
case "$line" in \{*) ;; *) continue ;; esac case "$line" in \{*) ;; *) continue ;; esac
# Felder aus dem JSON ziehen (jq-frei, damit kein Extra-Paket nötig ist) # Felder aus dem JSON ziehen (jq-frei, damit kein Extra-Paket nötig ist)
+1 -1
View File
@@ -17,6 +17,6 @@
[[inputs.exec]] [[inputs.exec]]
interval = "30s" interval = "30s"
timeout = "25s" timeout = "28s"
data_format = "influx" data_format = "influx"
commands = ["/etc/telegraf/journal-tail.sh"] commands = ["/etc/telegraf/journal-tail.sh"]