From b7b6f132f88e0063c99c975b73e6c64f01c8bf4c Mon Sep 17 00:00:00 2001 From: Benedikt Ritter Date: Wed, 3 Jul 2024 19:38:26 +0200 Subject: [PATCH] modules (monitoring): Add scrape config for nextcloud-cron This unit is currently logging JSON, which is hard to read. This adds promtail pipeline stages to extract JSON fields into labels and replace the log line with the message field. --- modules/nixos/monitoring/default.nix | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/modules/nixos/monitoring/default.nix b/modules/nixos/monitoring/default.nix index 244d1bf..410fdd9 100644 --- a/modules/nixos/monitoring/default.nix +++ b/modules/nixos/monitoring/default.nix @@ -52,6 +52,53 @@ in { target_label = "unit"; } ]; + pipeline_stages = [ + { + match = { + selector = "{unit=\"nextcloud-cron.service\"}"; + stages = [ + { + json = { + expressions = { + level = "level"; + timestamp = "time"; + message = "message"; + request_id = "reqId"; + remote_address = "remoteAddr"; + user = "user"; + app = "app"; + method = "method"; + url = "url"; + user_agent = "userAgent"; + version = "version"; + data = "data"; + }; + }; + } + { + labels = { + level = ""; + timestamp = ""; + request_id = ""; + remote_address = ""; + user = ""; + app = ""; + method = ""; + url = ""; + user_agent = ""; + version = ""; + data = ""; + }; + } + { + output = { + source = "message"; + }; + } + ]; + }; + } + ]; } ]; };