From 891a8f95669205bf452a896f0a350de081c6ba0c Mon Sep 17 00:00:00 2001 From: Davide Principi Date: Thu, 12 Sep 2024 09:23:59 +0200 Subject: [PATCH] Limit log query result size (#26) Set a max number of records returned by Loki to avoid leaking memory. Refs NethServer/dev#6978 --- imageroot/bin/cloud-log-manager-forwarder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imageroot/bin/cloud-log-manager-forwarder b/imageroot/bin/cloud-log-manager-forwarder index 8a5d66c..dbf8c54 100755 --- a/imageroot/bin/cloud-log-manager-forwarder +++ b/imageroot/bin/cloud-log-manager-forwarder @@ -76,7 +76,7 @@ logs_list = [] while True: try: # LogCLI command - logcli_command = ["logcli", "query", "--limit", "0", "--forward", "--timezone", "UTC", "--from", last_timestamp, "--no-labels", "-q", "-o", "jsonl", + logcli_command = ["logcli", "query", "--limit", "2000", "--forward", "--timezone", "UTC", "--from", last_timestamp, "--no-labels", "-q", "-o", "jsonl", '{node_id=~".+"} | json identifier="SYSLOG_IDENTIFIER", priority="PRIORITY", message="MESSAGE" | line_format "<{{.priority}}> [{{.node_id}}:{{.module_id}}:{{.identifier}}]: {{.message}}"'] response = subprocess.run(logcli_command, capture_output=True, text=True, timeout=300)