diff --git a/managed/services/agents/mongodb.go b/managed/services/agents/mongodb.go index a75ae50a1e..1a0e193a46 100644 --- a/managed/services/agents/mongodb.go +++ b/managed/services/agents/mongodb.go @@ -40,7 +40,7 @@ var ( newMongoExporterPMMVersion = version.MustParse("2.9.99") v2_24_99 = version.MustParse("2.24.99") v2_25_99 = version.MustParse("2.25.99") - v2_41_1 = version.MustParse("2.41.1") + v2_41_2 = version.MustParse("2.41.2") ) // mongodbExporterConfig returns desired configuration of mongodb_exporter process. @@ -53,11 +53,11 @@ func mongodbExporterConfig(node *models.Node, service *models.Service, exporter var args []string // Starting with PMM 2.10.0, we are shipping the new mongodb_exporter // Starting with PMM 2.25.0, we change the discovering-mode making it to discover all databases. - // Starting with PMM 2.41.1 we added shards collector. // Until now, discovering mode was not working properly and was enabled only if mongodb.collstats-colls= // was specified in the command line. + // Starting with PMM 2.41.1 we added shards collector. switch { - case !pmmAgentVersion.Less(v2_41_1): // >= 2.41.1 + case strings.Contains(pmmAgentVersion.String(), "2.41.1") || !pmmAgentVersion.Less(v2_41_2): // >= 2.41.1 args = v226Args(exporter, tdp, listenAddress) if exporter.MongoDBOptions != nil && exporter.MongoDBOptions.EnableAllCollectors { diff --git a/managed/services/agents/mongodb_test.go b/managed/services/agents/mongodb_test.go index 8accc04e9e..89dddbff25 100644 --- a/managed/services/agents/mongodb_test.go +++ b/managed/services/agents/mongodb_test.go @@ -231,6 +231,44 @@ func TestMongodbExporterConfig226(t *testing.T) { }) } +func Test241PatchVersion(t *testing.T) { + versions := map[string]bool{ + "2.43.0": true, + "2.42.2": true, + "2.41.1": true, + "2.41.1-HEAD-xyz": true, + "2.41.0": false, + } + for pmmVersion, shardsCompatibility := range versions { + pmmAgentVersion := version.MustParse(pmmVersion) + node := &models.Node{ + Address: "1.2.3.4", + } + mongodb := &models.Service{ + Address: pointer.ToString("1.2.3.4"), + Port: pointer.ToUint16(27017), + } + exporter := &models.Agent{ + AgentID: "agent-id", + AgentType: models.MongoDBExporterType, + Username: pointer.ToString("username"), + Password: pointer.ToString("s3cur3 p@$$w0r4."), + AgentPassword: pointer.ToString("agent-password"), + } + exporter.MongoDBOptions = &models.MongoDBOptions{ + EnableAllCollectors: true, + } + actual, err := mongodbExporterConfig(node, mongodb, exporter, exposeSecrets, pmmAgentVersion) + require.NoError(t, err) + if shardsCompatibility { + require.Contains(t, actual.Args, "--collector.shards") + } else { + require.NotContains(t, actual.Args, "--collector.shards") + } + + } +} + func TestMongodbExporterConfig2411(t *testing.T) { pmmAgentVersion := version.MustParse("2.41.1") node := &models.Node{ diff --git a/managed/services/victoriametrics/scrape_configs.go b/managed/services/victoriametrics/scrape_configs.go index 02a6d05bb5..3da84f7f00 100644 --- a/managed/services/victoriametrics/scrape_configs.go +++ b/managed/services/victoriametrics/scrape_configs.go @@ -403,7 +403,7 @@ func scrapeConfigsForMongoDBExporter(s *models.MetricsResolutions, params *scrap "indexstats", "collstats", } - if params.pmmAgentVersion != nil && !params.pmmAgentVersion.Less(version.MustParse("2.41.1")) { + if params.pmmAgentVersion != nil && (strings.Contains(params.pmmAgentVersion.String(), "2.41.1") || !params.pmmAgentVersion.Less(version.MustParse("2.41.2"))) { defaultCollectors = append(defaultCollectors, "shards") }