prometheus prefix

This commit is contained in:
rasmus 2022-11-06 17:02:49 +02:00
parent b323e34ff2
commit 28a518be7f
3 changed files with 18 additions and 4 deletions

View File

@ -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))
}

View File

@ -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",

View File

@ -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",