metrics: move Subsystem to constants

This commit is contained in:
rasmus 2022-11-09 21:13:36 +02:00
parent db30464aef
commit 1218016ca1
4 changed files with 55 additions and 63 deletions

View File

@ -6,28 +6,26 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
)
const promSubsystem = "file"
var (
promFileInitialSeekSkipped = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "file",
Name: "skipped_bytes",
Help: "Bytes skipped in file after discovering",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "skipped_bytes",
Help: "Bytes skipped in file after discovering",
}, []string{"filename"})
promFileCatchupDone = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: globals.PrometheusPrefix,
Subsystem: "file",
Name: "catchupped",
Help: "(0 or) 1 if initial backlog has been sent; (total <= watcher_file_count)",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "catchupped",
Help: "(0 or) 1 if initial backlog has been sent; (total <= watcher_file_count)",
}, []string{"filename"})
promFileErr = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: globals.PrometheusPrefix,
Subsystem: "file",
Name: "errors_count",
Help: "Errors while reading file",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "errors_count",
Help: "Errors while reading file",
}, []string{"filename"})
promFileLineSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "file",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "line_size_bytes",
Help: "Log line size in bytes",
Buckets: []float64{80, 160, 320, 640, 1280},

View File

@ -6,18 +6,18 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
)
const promSubsystem = "record"
var (
promRecordDroppedTooLarge = promauto.NewCounterVec(prom.CounterOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "record",
Name: "dropped_lines", // "dropped",
Help: "Records dropped due to being too large",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "dropped_lines", // "dropped",
Help: "Records dropped due to being too large",
}, []string{"filename"})
promRecordPrefixParsingErr = promauto.NewCounterVec(prom.CounterOpts{
Namespace: globals.PrometheusPrefix,
Subsystem: "record",
Name: "parsing_errors",
Help: "Errors while parsing log line prefixes",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "parsing_errors",
Help: "Errors while parsing log line prefixes",
}, []string{"filename"})
)

View File

@ -6,36 +6,33 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
)
const promSubsystem = "shipper"
var (
promShipperQueued = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "shipper",
Name: "shipper_record", // "queued",
Help: "Log records in queue to be batched and sent to database",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "shipper_record", // "queued",
Help: "Log records in queue to be batched and sent to database",
}, []string{"filename"})
promShipperDbSent = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "shipper",
Name: "record", // "sent",
Help: "Log records successfully committed to database",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "record", // "sent",
Help: "Log records successfully committed to database",
}, []string{"filename"})
promShipperBatchSizeResult = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "shipper",
Name: "bulk_submission_message", // "items_in_batch"
Help: "Batch size for database submissions",
Buckets: []float64{1, 5, 10, 50, 100, 500, 1000, 5000, 10000},
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "bulk_submission_message", // "items_in_batch"
Help: "Batch size for database submissions",
Buckets: []float64{1, 5, 10, 50, 100, 500, 1000, 5000, 10000},
})
promShipperDbSendError = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "shipper",
Name: "insertion_error", // "errors",
Help: "Failed database bulk insertions",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "insertion_error", // "errors",
Help: "Failed database bulk insertions",
}, []string{"filename"})
promShipperSynced = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: globals.PrometheusPrefix,
Subsystem: "shipper",
Name: "batches_synced",
Help: "All batches available have been committed database (0 or 1)",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "batches_synced",
Help: "All batches available have been committed database (0 or 1)",
}, []string{"filename"})
)

View File

@ -6,35 +6,32 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
)
const promSubsystem = "watcher"
var (
promWatcherOnline = promauto.NewGauge(prom.GaugeOpts{
Namespace: globals.PrometheusPrefix,
Subsystem: "watcher",
Name: "online",
Help: "1 if initialized, and directory watcher has been engaged successfully",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "online",
Help: "1 if initialized, and directory watcher has been engaged successfully",
})
promWatcherErr = promauto.NewCounter(prom.CounterOpts{
Namespace: globals.PrometheusPrefix,
Subsystem: "watcher",
Name: "errors",
Help: "Error in logmower watching log files",
Namespace: globals.PrometheusPrefix, Subsystem: promSubsystem,
Name: "errors",
Help: "Error in logmower watching log files",
})
promWatcherFilesStarted = promauto.NewCounter(prom.CounterOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "watcher",
Name: "log_file", // "discovered_logfiles",
Help: "Number of tracked log files",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "log_file", // "discovered_logfiles",
Help: "Number of tracked log files",
})
promWatcherFilesSkipped = promauto.NewCounter(prom.CounterOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "watcher",
Name: "invalid_filename", // "skipped_files",
Help: "Number of files in log directory skipped due to unexpected filename",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "invalid_filename", // "skipped_files",
Help: "Number of files in log directory skipped due to unexpected filename",
})
promWatcherEvents = promauto.NewCounter(prom.CounterOpts{
Namespace: globals.PrometheusPrefix,
// Subsystem: "watcher",
Name: "inotify_event", // "events",
Help: "Number of events while watchng (includes initial create events for existing file discovery)",
Namespace: globals.PrometheusPrefix, // Subsystem: promSubsystem,
Name: "inotify_event", // "events",
Help: "Number of events while watchng (includes initial create events for existing file discovery)",
})
)