From a264c571f3b3bc096df11f84f8fd8c48ff591923 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Aug 2016 20:37:53 +0200 Subject: logf: survive non-JSON input --- krebs/5pkgs/logf/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'krebs') diff --git a/krebs/5pkgs/logf/default.nix b/krebs/5pkgs/logf/default.nix index d73a1817a..b575c1879 100644 --- a/krebs/5pkgs/logf/default.nix +++ b/krebs/5pkgs/logf/default.nix @@ -31,7 +31,7 @@ pkgs.writeDashBin "logf" '' -o PreferredAuthentications=publickey \ -o StrictHostKeyChecking=yes \ exec journalctl -af -n 0 -o json \ - | stdbuf -oL jq -Rf ${pkgs.writeJq "logf-remote-error.jq" '' + | stdbuf -oL jq -Rcf ${pkgs.writeJq "logf-remote-error.jq" '' { PRIORITY: "4", MESSAGE: ., @@ -41,7 +41,7 @@ pkgs.writeDashBin "logf" '' sleep 10m exec "$0" "$@" ''} \ - | ${pkgs.jq}/bin/jq -rf ${pkgs.writeJq "logf-filter.jq" '' + | ${pkgs.jq}/bin/jq -Rrf ${pkgs.writeJq "logf-filter.jq" '' (env.LOGF_HOST_COLORS | fromjson) as $host_colors | (env.LOGF_PRIO_COLORS | fromjson) as $prio_colors | @@ -93,6 +93,11 @@ pkgs.writeDashBin "logf" '' #| agsub("Start queue"; "\(.)\u0007" | col(fg(42); $prio_c)) | col($prio_c); + try fromjson catch { + _SOURCE_REALTIME_TIMESTAMP: now | tostring | sub("[.]"; ""), + SYSLOG_IDENTIFIER: "logf/journalctl", + MESSAGE: ., + } | [ p_time , p_host -- cgit v1.2.3