From 31dca057eaf7d4484d0b89d0fa107f4c9ad4aa7c Mon Sep 17 00:00:00 2001 From: hiroshi Date: Sat, 12 Jun 2021 11:55:58 +0900 Subject: [PATCH 01/20] replSetGetConfigCollector. it just works --- exporter/exporter.go | 9 ++++ exporter/metrics.go | 3 ++ exporter/replset_config_collector.go | 70 ++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 exporter/replset_config_collector.go diff --git a/exporter/exporter.go b/exporter/exporter.go index 27fd0f024..de742508f 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -153,6 +153,15 @@ func (e *Exporter) makeRegistry(ctx context.Context, client *mongo.Client, topol registry.MustRegister(&rsgsc) } + rsgcc := replSetGetConfigCollector{ + ctx: ctx, + client: client, + compatibleMode: e.opts.CompatibleMode, + logger: e.opts.Logger, + topologyInfo: topologyInfo, + } + registry.MustRegister(&rsgcc) + return registry } diff --git a/exporter/metrics.go b/exporter/metrics.go index e8dca5fc7..3421c452f 100644 --- a/exporter/metrics.go +++ b/exporter/metrics.go @@ -319,6 +319,9 @@ func processSlice(prefix, k string, v []interface{}, commonLabels map[string]str if state, ok := s["stateStr"].(string); ok { labels["member_state"] = state } + if state, ok := s["host"].(string); ok { + labels["host"] = state + } metrics = append(metrics, makeMetrics(prefix+k, s, labels, compatibleMode)...) } diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go new file mode 100644 index 000000000..8bcc01082 --- /dev/null +++ b/exporter/replset_config_collector.go @@ -0,0 +1,70 @@ +// mongodb_exporter +// Copyright (C) 2017 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package exporter + +import ( + "context" + + "github.com/prometheus/client_golang/prometheus" + "github.com/sirupsen/logrus" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" +) + +// const ( +// replicationNotEnabled = 76 +// replicationNotYetInitialized = 94 +// ) + +type replSetGetConfigCollector struct { + ctx context.Context + client *mongo.Client + compatibleMode bool + logger *logrus.Logger + topologyInfo labelsGetter +} + +func (d *replSetGetConfigCollector) Describe(ch chan<- *prometheus.Desc) { + prometheus.DescribeByCollect(d, ch) +} + +func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) { + cmd := bson.D{{Key: "replSetGetConfig", Value: "1"}} + res := d.client.Database("admin").RunCommand(d.ctx, cmd) + + var m bson.M + + if err := res.Decode(&m); err != nil { + if e, ok := err.(mongo.CommandError); ok { + if e.Code == replicationNotYetInitialized || e.Code == replicationNotEnabled { + return + } + } + d.logger.Errorf("cannot get replSetGetConfig: %s", err) + + return + } + + d.logger.Debug("replSetGetConfig result:") + debugResult(d.logger, m) + + for _, metric := range makeMetrics("cfg", m, d.topologyInfo.baseLabels(), d.compatibleMode) { + ch <- metric + } +} + +var _ prometheus.Collector = (*replSetGetConfigCollector)(nil) From ff968d7967ac4e334cda95f62b2034fda6b1e1b8 Mon Sep 17 00:00:00 2001 From: hiroshi Date: Sun, 13 Jun 2021 14:57:54 +0900 Subject: [PATCH 02/20] Use member_idx for host field to match with replStatus --- exporter/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/metrics.go b/exporter/metrics.go index 3421c452f..efbea1eb9 100644 --- a/exporter/metrics.go +++ b/exporter/metrics.go @@ -319,8 +319,8 @@ func processSlice(prefix, k string, v []interface{}, commonLabels map[string]str if state, ok := s["stateStr"].(string); ok { labels["member_state"] = state } - if state, ok := s["host"].(string); ok { - labels["host"] = state + if host, ok := s["host"].(string); ok { + labels["member_idx"] = host } metrics = append(metrics, makeMetrics(prefix+k, s, labels, compatibleMode)...) From 0837f71697cbb67d97b2bbe07a8cfba8fbf19d1e Mon Sep 17 00:00:00 2001 From: hiroshi Date: Sun, 13 Jun 2021 15:21:48 +0900 Subject: [PATCH 03/20] Add --disable.replicasetconfig option flag --- README.md | 1 + exporter/exporter.go | 17 ++++++++++------- exporter/replset_config_collector.go | 10 ++++++++++ main.go | 2 ++ main_test.go | 1 + 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5318c0117..7119e7723 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Currently, these metric sources are implemented: |\-\-log.level|Only log messages with the given severity or above. Valid levels: [debug, info, warn, error]|\-\-log.level="error"| |\-\-disable.diagnosticdata|Disable collecting metrics from getDiagnosticData|| |\-\-disable.replicasetstatus|Disable collecting metrics from replSetGetStatus|| +|\-\-disable.replicasetconfig|Disable collecting metrics from replSetGetConfig|| |--version|Show version and exit| ### Build the exporter diff --git a/exporter/exporter.go b/exporter/exporter.go index de742508f..7c97d6a7d 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -54,6 +54,7 @@ type Opts struct { Logger *logrus.Logger DisableDiagnosticData bool DisableReplicasetStatus bool + DisableReplicasetConfig bool } var ( @@ -153,14 +154,16 @@ func (e *Exporter) makeRegistry(ctx context.Context, client *mongo.Client, topol registry.MustRegister(&rsgsc) } - rsgcc := replSetGetConfigCollector{ - ctx: ctx, - client: client, - compatibleMode: e.opts.CompatibleMode, - logger: e.opts.Logger, - topologyInfo: topologyInfo, + if !e.opts.DisableReplicasetConfig { + rsgcc := replSetGetConfigCollector{ + ctx: ctx, + client: client, + compatibleMode: e.opts.CompatibleMode, + logger: e.opts.Logger, + topologyInfo: topologyInfo, + } + registry.MustRegister(&rsgcc) } - registry.MustRegister(&rsgcc) return registry } diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index 8bcc01082..987a86c21 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -19,6 +19,7 @@ package exporter import ( "context" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" "go.mongodb.org/mongo-driver/bson" @@ -59,6 +60,15 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) { return } + config, ok := m["config"].(bson.M) + if !ok { + err := errors.Wrapf(errUnexpectedDataType, "%T for data field", m["config"]) + d.logger.Errorf("cannot decode getDiagnosticData: %s", err) + + return + } + m = config + d.logger.Debug("replSetGetConfig result:") debugResult(d.logger, m) diff --git a/main.go b/main.go index 5ebaaf289..6f21709dd 100644 --- a/main.go +++ b/main.go @@ -47,6 +47,7 @@ type GlobalFlags struct { DisableDiagnosticData bool `name:"disable.diagnosticdata" help:"Disable collecting metrics from getDiagnosticData"` DisableReplicasetStatus bool `name:"disable.replicasetstatus" help:"Disable collecting metrics from replSetGetStatus"` + DisableReplicasetConfig bool `name:"disable.replicasetconfig" help:"Disable collecting metrics from replSetGetConfig"` DiscoveringMode bool `name:"discovering-mode" help:"Enable autodiscover collections"` CompatibleMode bool `name:"compatible-mode" help:"Enable old mongodb-exporter compatible metrics"` @@ -116,6 +117,7 @@ func buildExporter(opts GlobalFlags) (*exporter.Exporter, error) { WebListenAddress: opts.WebListenAddress, DisableDiagnosticData: opts.DisableDiagnosticData, DisableReplicasetStatus: opts.DisableReplicasetStatus, + DisableReplicasetConfig: opts.DisableReplicasetConfig, DirectConnect: opts.DirectConnect, } diff --git a/main_test.go b/main_test.go index cfcdf35ee..15f83e404 100644 --- a/main_test.go +++ b/main_test.go @@ -18,6 +18,7 @@ func TestBuildExporter(t *testing.T) { DisableDiagnosticData: true, DisableReplicasetStatus: true, + DisableReplicasetConfig: true, CompatibleMode: true, } From 54ded8c406cd4412f1b19a4439fca84bbcfe07ed Mon Sep 17 00:00:00 2001 From: hiroshi Date: Mon, 20 Sep 2021 15:02:01 +0900 Subject: [PATCH 04/20] Use errors.As() instead of type assertion. --- exporter/replset_config_collector.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index 987a86c21..9fa77f823 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -50,7 +50,8 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) { var m bson.M if err := res.Decode(&m); err != nil { - if e, ok := err.(mongo.CommandError); ok { + var e *mongo.CommandError + if errors.As(err, &e) { if e.Code == replicationNotYetInitialized || e.Code == replicationNotEnabled { return } From 22b9fe372e0bac1c66506516728d7ff096293893 Mon Sep 17 00:00:00 2001 From: hiroshi Date: Mon, 20 Sep 2021 15:23:55 +0900 Subject: [PATCH 05/20] Add replset_config_collector_test. --- exporter/replset_config_collector_test.go | 80 +++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 exporter/replset_config_collector_test.go diff --git a/exporter/replset_config_collector_test.go b/exporter/replset_config_collector_test.go new file mode 100644 index 000000000..1bdc66d0f --- /dev/null +++ b/exporter/replset_config_collector_test.go @@ -0,0 +1,80 @@ +// mongodb_exporter +// Copyright (C) 2017 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package exporter + +import ( + "context" + "strings" + "testing" + "time" + + "github.com/prometheus/client_golang/prometheus/testutil" + "github.com/sirupsen/logrus" + "github.com/stretchr/testify/assert" + + "github.com/percona/mongodb_exporter/internal/tu" +) + +func TestReplsetConfigCollector(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + + client := tu.DefaultTestClient(ctx, t) + + ti := labelsGetterMock{} + + c := &replSetGetConfigCollector{ + ctx: ctx, + client: client, + logger: logrus.New(), + topologyInfo: ti, + } + + // The last \n at the end of this string is important + expected := strings.NewReader(` +# HELP mongodb_cfg_protocolVersion cfg. +# TYPE mongodb_cfg_protocolVersion untyped +mongodb_cfg_protocolVersion 1` + "\n") + // Filter metrics for 2 reasons: + // 1. The result is huge + // 2. We need to check against know values. Don't use metrics that return counters like uptime + // or counters like the number of transactions because they won't return a known value to compare + filter := []string{ + "mongodb_cfg_protocolVersion", + } + err := testutil.CollectAndCompare(c, expected, filter...) + assert.NoError(t, err) +} + +func TestReplsetConfigCollectorNoSharding(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + + client := tu.TestClient(ctx, tu.MongoDBStandAlonePort, t) + + ti := labelsGetterMock{} + + c := &replSetGetConfigCollector{ + ctx: ctx, + client: client, + topologyInfo: ti, + } + + expected := strings.NewReader(``) + err := testutil.CollectAndCompare(c, expected) + assert.NoError(t, err) +} From 678e125dc61e474a704f13044f753ec9a99a3127 Mon Sep 17 00:00:00 2001 From: hiroshi Date: Mon, 20 Sep 2021 19:28:37 +0900 Subject: [PATCH 06/20] Revert "Use errors.As() instead of type assertion." This reverts commit 54ded8c406cd4412f1b19a4439fca84bbcfe07ed. --- exporter/replset_config_collector.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index 9fa77f823..987a86c21 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -50,8 +50,7 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) { var m bson.M if err := res.Decode(&m); err != nil { - var e *mongo.CommandError - if errors.As(err, &e) { + if e, ok := err.(mongo.CommandError); ok { if e.Code == replicationNotYetInitialized || e.Code == replicationNotEnabled { return } From bb9ecc8a5c61de9ad365fdbce30f8f4bf32c67b2 Mon Sep 17 00:00:00 2001 From: hiroshi Date: Tue, 21 Sep 2021 09:33:43 +0900 Subject: [PATCH 07/20] nolint - errors.As seems to cause segfault. --- exporter/replset_config_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index 987a86c21..24974bafe 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -50,7 +50,7 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) { var m bson.M if err := res.Decode(&m); err != nil { - if e, ok := err.(mongo.CommandError); ok { + if e, ok := err.(mongo.CommandError); ok { //nolint // https://github.com/percona/mongodb_exporter/pull/295#issuecomment-922874632 if e.Code == replicationNotYetInitialized || e.Code == replicationNotEnabled { return } From 1b2fe08f67946d524f4fe84bfeccdd70183704a1 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:06:34 +0300 Subject: [PATCH 08/20] Update exporter/replset_config_collector.go --- exporter/replset_config_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index ff9560a22..462c2ed97 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -92,7 +92,7 @@ func (d *replSetGetConfigCollector) collect(ch chan<- prometheus.Metric) { logger.Debug("replSetGetConfig result:") debugResult(logger, m) - for _, metric := range makeMetrics("cfg", m, d.topologyInfo.baseLabels(), d.compatibleMode) { + for _, metric := range makeMetrics("rs_cfg", m, d.topologyInfo.baseLabels(), d.compatibleMode) { ch <- metric } } From dc4899c0ae741dda57507c318df86aa3f1e84614 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:06:44 +0300 Subject: [PATCH 09/20] Update exporter/replset_config_collector_test.go --- exporter/replset_config_collector_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exporter/replset_config_collector_test.go b/exporter/replset_config_collector_test.go index ab338c7f7..3f89bebb6 100644 --- a/exporter/replset_config_collector_test.go +++ b/exporter/replset_config_collector_test.go @@ -41,9 +41,9 @@ func TestReplsetConfigCollector(t *testing.T) { // The last \n at the end of this string is important expected := strings.NewReader(` - # HELP mongodb_cfg_protocolVersion cfg. - # TYPE mongodb_cfg_protocolVersion untyped - mongodb_cfg_protocolVersion 1` + "\n") + # HELP mongodb_rs_cfg_protocolVersion cfg. + # TYPE mongodb_rs_cfg_protocolVersion untyped + mongodb_rs_cfg_protocolVersion 1` + "\n") // Filter metrics for 2 reasons: // 1. The result is huge // 2. We need to check against know values. Don't use metrics that return counters like uptime From 22cf389d6cb6fcf4c305b4dc2f8e487a682bac35 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:06:48 +0300 Subject: [PATCH 10/20] Update exporter/replset_config_collector.go --- exporter/replset_config_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index 462c2ed97..f321d25aa 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -43,7 +43,7 @@ type replSetGetConfigCollector struct { func newReplicationSetConfigCollector(ctx context.Context, client *mongo.Client, logger *logrus.Logger, compatible bool, topology labelsGetter) *replSetGetConfigCollector { return &replSetGetConfigCollector{ ctx: ctx, - base: newBaseCollector(client, logger), + base: newBaseCollector(client, logger.WithFields(logrus.Fields{"collector": "replset_config"})), compatibleMode: compatible, topologyInfo: topology, From 8d051b0f42322dc892283f000bebde4368f5b400 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:06:57 +0300 Subject: [PATCH 11/20] Update exporter/replset_config_collector_test.go --- exporter/replset_config_collector_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/replset_config_collector_test.go b/exporter/replset_config_collector_test.go index 3f89bebb6..da3af5ae8 100644 --- a/exporter/replset_config_collector_test.go +++ b/exporter/replset_config_collector_test.go @@ -49,7 +49,7 @@ func TestReplsetConfigCollector(t *testing.T) { // 2. We need to check against know values. Don't use metrics that return counters like uptime // or counters like the number of transactions because they won't return a known value to compare filter := []string{ - "mongodb_cfg_protocolVersion", + "mongodb_rs_cfg_protocolVersion", } err := testutil.CollectAndCompare(c, expected, filter...) assert.NoError(t, err) From ec5c37a84e6fef4bae8939d70fc740a3e7e9815c Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:07:04 +0300 Subject: [PATCH 12/20] Update exporter/replset_config_collector.go --- exporter/replset_config_collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index f321d25aa..82774d2a1 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -59,7 +59,7 @@ func (d *replSetGetConfigCollector) Collect(ch chan<- prometheus.Metric) { } func (d *replSetGetConfigCollector) collect(ch chan<- prometheus.Metric) { - defer prometheus.MeasureCollectTime(ch, "mongodb", "replset_config")() + defer measureCollectTime(ch, "mongodb", "replset_config")() logger := d.base.logger client := d.base.client From f5b0c15bc4d1d08cd4936fe647ed051900d3cea9 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:11:59 +0300 Subject: [PATCH 13/20] Update exporter/exporter.go --- exporter/exporter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/exporter.go b/exporter/exporter.go index 126306b7c..3db451c16 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -246,7 +246,7 @@ func (e *Exporter) makeRegistry(ctx context.Context, client *mongo.Client, topol rsgsc := newReplicationSetConfigCollector(ctx, client, e.opts.Logger, e.opts.CompatibleMode, topologyInfo) registry.MustRegister(rsgsc) - } + } if e.opts.EnableShards && nodeType == typeMongos && requestOpts.EnableShards { sc := newShardsCollector(ctx, client, e.opts.Logger, e.opts.CompatibleMode) registry.MustRegister(sc) From 58da23b653bc1abaf87cbec18453147cc207413f Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:12:04 +0300 Subject: [PATCH 14/20] Update exporter/exporter.go --- exporter/exporter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporter/exporter.go b/exporter/exporter.go index 3db451c16..dfed85093 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -382,8 +382,8 @@ func GetRequestOpts(filters []string, defaultOpts *Opts) Opts { requestOpts.EnableDiagnosticData = true case "replicasetstatus": requestOpts.EnableReplicasetStatus = true - case "replicasetconfig": - requestOpts.EnableReplicasetConfig = true + case "replicasetconfig": + requestOpts.EnableReplicasetConfig = true case "dbstats": requestOpts.EnableDBStats = true case "topmetrics": From 75ecc85a205b89dde9d9d0343de2546526e8d2f6 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:14:16 +0300 Subject: [PATCH 15/20] Update exporter/replset_config_collector_test.go --- exporter/replset_config_collector_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/exporter/replset_config_collector_test.go b/exporter/replset_config_collector_test.go index da3af5ae8..f6d7163da 100644 --- a/exporter/replset_config_collector_test.go +++ b/exporter/replset_config_collector_test.go @@ -63,11 +63,7 @@ func TestReplsetConfigCollectorNoSharding(t *testing.T) { ti := labelsGetterMock{} - c := &replSetGetConfigCollector{ - ctx: ctx, - client: client, - topologyInfo: ti, - } + c := newReplicationSetConfigCollector(ctx, client, logrus.New(), false, ti) // Replication set metrics should not be generated for unsharded server count := testutil.CollectAndCount(c) From 6578e6472d89a3394d593d5db9212191a8e0c901 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:17:53 +0300 Subject: [PATCH 16/20] Update replset_config_collector.go --- exporter/replset_config_collector.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index 82774d2a1..d32ab52fd 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -1,18 +1,17 @@ // mongodb_exporter // Copyright (C) 2017 Percona LLC // -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. +// http://www.apache.org/licenses/LICENSE-2.0 // -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. package exporter From 0857d3d35aeb9003143cafc31d24548885d2eef1 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:18:12 +0300 Subject: [PATCH 17/20] Update replset_config_collector_test.go --- exporter/replset_config_collector_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/exporter/replset_config_collector_test.go b/exporter/replset_config_collector_test.go index f6d7163da..94da633e8 100644 --- a/exporter/replset_config_collector_test.go +++ b/exporter/replset_config_collector_test.go @@ -1,18 +1,17 @@ // mongodb_exporter // Copyright (C) 2017 Percona LLC // -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. +// http://www.apache.org/licenses/LICENSE-2.0 // -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. package exporter From 08d54d22883413fbb7920770c65465486e43950f Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 10:19:12 +0300 Subject: [PATCH 18/20] Update exporter/replset_config_collector_test.go --- exporter/replset_config_collector_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/replset_config_collector_test.go b/exporter/replset_config_collector_test.go index 94da633e8..5fe456f2a 100644 --- a/exporter/replset_config_collector_test.go +++ b/exporter/replset_config_collector_test.go @@ -40,7 +40,7 @@ func TestReplsetConfigCollector(t *testing.T) { // The last \n at the end of this string is important expected := strings.NewReader(` - # HELP mongodb_rs_cfg_protocolVersion cfg. + # HELP mongodb_rs_cfg_protocolVersion rs_cfg. # TYPE mongodb_rs_cfg_protocolVersion untyped mongodb_rs_cfg_protocolVersion 1` + "\n") // Filter metrics for 2 reasons: From 12469dda125ad35ef5375ba2e7a3a922cd5dc4c0 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 11:14:28 +0300 Subject: [PATCH 19/20] Update exporter/replset_config_collector.go --- exporter/replset_config_collector.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index d32ab52fd..bdd79b946 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -25,10 +25,6 @@ import ( "go.mongodb.org/mongo-driver/mongo" ) -// const ( -// replicationNotEnabled = 76 -// replicationNotYetInitialized = 94 -// ) type replSetGetConfigCollector struct { ctx context.Context From d4c588d8ae5dea2f72e97784129c2389fb888f25 Mon Sep 17 00:00:00 2001 From: Nurlan Moldomurov Date: Mon, 11 Nov 2024 13:59:23 +0300 Subject: [PATCH 20/20] Update replset_config_collector.go --- exporter/replset_config_collector.go | 1 - 1 file changed, 1 deletion(-) diff --git a/exporter/replset_config_collector.go b/exporter/replset_config_collector.go index bdd79b946..6bb76f8f2 100644 --- a/exporter/replset_config_collector.go +++ b/exporter/replset_config_collector.go @@ -25,7 +25,6 @@ import ( "go.mongodb.org/mongo-driver/mongo" ) - type replSetGetConfigCollector struct { ctx context.Context base *baseCollector