From e065c155ccc1a9802048d475ee58f3475761173c Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 16 Aug 2024 12:58:24 +0200 Subject: [PATCH] Add command line flag to disable metrics about the exporter it-self (#885) PR #356 introduced an API option to disable default exporter metrics (process_* and go_*). However there is no command line flag to actually set this option. This change adds the command line flag `--no-collector.exporter-metrics` to disable those metrics. Signed-off-by: Christian Pointner Co-authored-by: Roman Novikov --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index 3add06b94..df2ec9806 100644 --- a/main.go +++ b/main.go @@ -49,6 +49,7 @@ type GlobalFlags struct { LogLevel string `name:"log.level" help:"Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]" enum:"debug,info,warn,error,fatal" default:"error"` ConnectTimeoutMS int `name:"mongodb.connect-timeout-ms" help:"Connection timeout in milliseconds" default:"5000"` + EnableExporterMetrics bool `name:"collector.exporter-metrics" help:"Enable collecting metrics about the exporter itself (process_*, go_*)" negatable:"" default:"True"` EnableDiagnosticData bool `name:"collector.diagnosticdata" help:"Enable collecting metrics from getDiagnosticData"` EnableReplicasetStatus bool `name:"collector.replicasetstatus" help:"Enable collecting metrics from replSetGetStatus"` EnableDBStats bool `name:"collector.dbstats" help:"Enable collecting metrics from dbStats"` @@ -147,6 +148,7 @@ func buildExporter(opts GlobalFlags, uri string, log *logrus.Logger) *exporter.E ConnectTimeoutMS: opts.ConnectTimeoutMS, TimeoutOffset: opts.TimeoutOffset, + DisableDefaultRegistry: !opts.EnableExporterMetrics, EnableDiagnosticData: opts.EnableDiagnosticData, EnableReplicasetStatus: opts.EnableReplicasetStatus, EnableCurrentopMetrics: opts.EnableCurrentopMetrics,