From 28a518be7f0fa03aefda2b6845ffa5d4e0ab797d Mon Sep 17 00:00:00 2001 From: rasmus Date: Sun, 6 Nov 2022 17:02:49 +0200 Subject: [PATCH] prometheus prefix --- cmd/mower.go | 12 ++++++++---- cmd/sender.go | 8 ++++++++ cmd/submit.go | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/mower.go b/cmd/mower.go index da05476..86b4dfd 100644 --- a/cmd/mower.go +++ b/cmd/mower.go @@ -26,8 +26,9 @@ import ( ) const ( - MACHINEID = "/etc/machine-id" - MONGO_TIMEOUT = 10 * time.Second + MachineId = "/etc/machine-id" + MongoTimeout = 10 * time.Second + PrometheusPrefix = "logmower-shipper" ) // wrapper to force copying before use @@ -41,7 +42,7 @@ func defaultBackoff() wait.Backoff { } func mongoTimeoutCtx(ctx context.Context) context.Context { - ctx, _ = context.WithTimeout(ctx, MONGO_TIMEOUT) //nolint:lostcancel (cancelled by mongo, should be bug on them //TODO) + ctx, _ = context.WithTimeout(ctx, MongoTimeout) //nolint:lostcancel (cancelled by mongo, should be bug on them //TODO) return ctx } @@ -78,17 +79,20 @@ var App = &cli.App{ var ( promWatcherOnline = promauto.NewGauge(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "watcher", Name: "online", Help: "1 if initialized, and directory watcher has been engaged successfully", }) promErrWatching = promauto.NewCounter(prom.CounterOpts{ + Namespace: PrometheusPrefix, Subsystem: "watcher", Name: "errors", Help: "Error in logmower watching log files", }) promFilesRead = promauto.NewCounter(prom.CounterOpts{ + Namespace: PrometheusPrefix, Subsystem: "watcher", Name: "seen_files", Help: "Number of tracked log files", @@ -214,7 +218,7 @@ func getHostInfo(nodeName string) (h HostInfo, err error) { } h.name = strings.TrimSpace(nodeName) - id, errL := os.ReadFile(MACHINEID) + id, errL := os.ReadFile(MachineId) if errL != nil { err = errAppend(err, fmt.Errorf("id: %w", errL)) } diff --git a/cmd/sender.go b/cmd/sender.go index 7fa2e0f..f80f7f6 100644 --- a/cmd/sender.go +++ b/cmd/sender.go @@ -13,26 +13,31 @@ import ( var ( promShipperMongoSent = promauto.NewCounterVec(prom.CounterOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "sent", Help: "Log lines successfully committed to mongo", }, []string{"filename"}) promShipperMongoSentError = promauto.NewCounterVec(prom.CounterOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "mongo_errors", Help: "Errors while submitting to mongo", // TODO: }, []string{"filename"}) promLineParsingErr = promauto.NewCounterVec(prom.CounterOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "lines_parsing_errors", Help: "Errors while parsing log line suffixes", }, []string{"filename"}) promShipperQueued = promauto.NewGaugeVec(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "queued", Help: "Log lines in queue to be batched and sent to mongo", }, []string{"filename"}) promShipperSynced = promauto.NewGaugeVec(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "batches_synced", Help: "All batches available have been sent to mongo", @@ -46,6 +51,7 @@ const ( func init() { promauto.NewGaugeFunc(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "queue_size", Help: "Submit queue size cap", @@ -53,6 +59,7 @@ func init() { return float64(SendQueueLimit) }) promauto.NewGaugeFunc(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "batch_size", Help: "batching size cap", @@ -60,6 +67,7 @@ func init() { return float64(MaxBatchItems) }) promauto.NewGaugeFunc(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "shipper", Name: "batch_time", Help: "batching delay cap", diff --git a/cmd/submit.go b/cmd/submit.go index b1a8391..ad9e7e4 100644 --- a/cmd/submit.go +++ b/cmd/submit.go @@ -23,11 +23,13 @@ import ( var ( promCatchupDone = promauto.NewGaugeVec(prom.GaugeOpts{ + Namespace: PrometheusPrefix, Subsystem: "file", Name: "catchupped", Help: "Files where initial backlog has been sent; (total <= watcher_file_count)", }, []string{"filename"}) // TODO: rm filename? promFileErr = promauto.NewCounterVec(prom.CounterOpts{ + Namespace: PrometheusPrefix, Subsystem: "file", Name: "errors_count", Help: "Error count for reading files",