From 42da569bcd59a7de7b5eaf39626adbf16aa91aa6 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 2 Dec 2019 14:03:44 +0200 Subject: [PATCH] lib/logger: merge `file` and `line` labels into `location="file:line"` This should improve the usability for `vm_log_messages_total` metric during practical queries --- lib/logger/logger.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/logger/logger.go b/lib/logger/logger.go index ab411e3f08..80e7a97a7b 100644 --- a/lib/logger/logger.go +++ b/lib/logger/logger.go @@ -123,7 +123,8 @@ func logMessage(level, msg string, skipframes int) { mu.Unlock() // Increment vm_log_messages_total - counterName := fmt.Sprintf(`vm_log_messages_total{app_version=%q, level=%q, file=%q, line="%d"}`, buildinfo.Version, levelLowercase, file, line) + location := fmt.Sprintf("%s:%d", file, line) + counterName := fmt.Sprintf(`vm_log_messages_total{app_version=%q, level=%q, location=%q}`, buildinfo.Version, levelLowercase, location) metrics.GetOrCreateCounter(counterName).Inc() switch level {