mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/logger: track the number of log messages by (level, file, line)
in the vm_log_messages_count
metric
This commit is contained in:
parent
761645b20a
commit
c567919f80
1 changed files with 7 additions and 0 deletions
|
@ -11,6 +11,9 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo"
|
||||||
|
"github.com/VictoriaMetrics/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
var loggerLevel = flag.String("loggerLevel", "INFO", "Minimum level of errors to log. Possible values: INFO, ERROR, FATAL, PANIC")
|
var loggerLevel = flag.String("loggerLevel", "INFO", "Minimum level of errors to log. Possible values: INFO, ERROR, FATAL, PANIC")
|
||||||
|
@ -119,6 +122,10 @@ func logMessage(level, msg string, skipframes int) {
|
||||||
fmt.Fprint(os.Stderr, logMsg)
|
fmt.Fprint(os.Stderr, logMsg)
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
||||||
|
// Increment vm_log_messages_count
|
||||||
|
counterName := fmt.Sprintf(`vm_log_messages_count{app_version=%q, level=%q, file=%q, line="%d"}`, buildinfo.Version, levelLowercase, file, line)
|
||||||
|
metrics.GetOrCreateCounter(counterName).Inc()
|
||||||
|
|
||||||
switch level {
|
switch level {
|
||||||
case "PANIC":
|
case "PANIC":
|
||||||
panic(errors.New(msg))
|
panic(errors.New(msg))
|
||||||
|
|
Loading…
Reference in a new issue