Skip to content

Commit b419495

Browse files
committed
Allow use of server status collector with new flag
This is useful when running the exporter against mongos instances where getDiagnosticData is not available.
1 parent a627fc7 commit b419495

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

exporter/exporter.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type Opts struct {
6666
EnableDBStatsFreeStorage bool
6767
EnableDiagnosticData bool
6868
EnableReplicasetStatus bool
69+
EnableServerStatus bool
6970
EnableCurrentopMetrics bool
7071
EnableTopMetrics bool
7172
EnableIndexStats bool
@@ -172,6 +173,7 @@ func (e *Exporter) makeRegistry(ctx context.Context, client *mongo.Client, topol
172173
e.opts.EnableCollStats = true
173174
e.opts.EnableTopMetrics = true
174175
e.opts.EnableReplicasetStatus = true
176+
e.opts.EnableServerStatus = true
175177
e.opts.EnableIndexStats = true
176178
e.opts.EnableCurrentopMetrics = true
177179
e.opts.EnableProfile = true
@@ -242,6 +244,12 @@ func (e *Exporter) makeRegistry(ctx context.Context, client *mongo.Client, topol
242244
registry.MustRegister(rsgsc)
243245
}
244246

247+
if e.opts.EnableServerStatus {
248+
ssc := newServerStatusCollector(ctx, client, e.opts.Logger,
249+
e.opts.CompatibleMode, topologyInfo)
250+
registry.MustRegister(ssc)
251+
}
252+
245253
return registry
246254
}
247255

@@ -303,6 +311,8 @@ func (e *Exporter) Handler() http.Handler {
303311
requestOpts.EnableDiagnosticData = true
304312
case "replicasetstatus":
305313
requestOpts.EnableReplicasetStatus = true
314+
case "serverstatus":
315+
requestOpts.EnableServerStatus = true
306316
case "dbstats":
307317
requestOpts.EnableDBStats = true
308318
case "topmetrics":

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type GlobalFlags struct {
4848

4949
EnableDiagnosticData bool `name:"collector.diagnosticdata" help:"Enable collecting metrics from getDiagnosticData"`
5050
EnableReplicasetStatus bool `name:"collector.replicasetstatus" help:"Enable collecting metrics from replSetGetStatus"`
51+
EnableServerStatus bool `name:"collector.serverstatus" help:"Enable collecting metrics from serverStatus"`
5152
EnableDBStats bool `name:"collector.dbstats" help:"Enable collecting metrics from dbStats"`
5253
EnableDBStatsFreeStorage bool `name:"collector.dbstatsfreestorage" help:"Enable collecting free space metrics from dbStats"`
5354
EnableTopMetrics bool `name:"collector.topmetrics" help:"Enable collecting metrics from top admin command"`
@@ -143,6 +144,7 @@ func buildExporter(opts GlobalFlags) *exporter.Exporter {
143144

144145
EnableDiagnosticData: opts.EnableDiagnosticData,
145146
EnableReplicasetStatus: opts.EnableReplicasetStatus,
147+
EnableServerStatus: opts.EnableServerStatus,
146148
EnableCurrentopMetrics: opts.EnableCurrentopMetrics,
147149
EnableTopMetrics: opts.EnableTopMetrics,
148150
EnableDBStats: opts.EnableDBStats,

0 commit comments

Comments
 (0)